On Feb 22, 2011, at 11:27 PM, Andrey Rahmatullin wrote:
>On Tue, Feb 22, 2011 at 07:23:51PM +0100, Vincent Bernat wrote:
>> I wasn't aware of the existence of a test target.
>It's a setuptools feature if I understand correctly
>(setuptools.command.test) and it needs specific test* arguments to
>setup(). Not all modules support it, some have custom runtests.sh scripts.
It's rumored to be part of setuptools, but of course we use distribute :).
There it works very nicely, and even integrates with 2to3, including
conversion of doctests. From my setup.py:
-----snip snip-----
setup(
# ...
test_suite='flufl.i18n.tests',
# Auto-conversion to Python 3.
use_2to3=True,
convert_2to3_doctests=find_doctests(),
use_2to3_fixers=['myfixers'],
# ...
-----snip snip-----
find_doctests() is part of my setup_helpers package:
-----snip snip-----
def find_doctests(start='.', extension='.txt'):
"""Find separate-file doctests in the package.
This is useful for Distribute's automatic 2to3 conversion support. The
`setup()` keyword argument `convert_2to3_doctests` requires file names,
which may be difficult to track automatically as you add new doctests.
:param start: Directory to start searching in (default is cwd)
:type start: string
:param extension: Doctest file extension (default is .txt)
:type extension: string
:return: The doctest files found.
:rtype: list
"""
doctests = []
for dirpath, dirnames, filenames in os.walk(start):
doctests.extend(os.path.join(dirpath, filename)
for filename in filenames
if filename.endswith(extension))
return doctests
-----snip snip-----
I'd really love to see `python setup.py test` as the standard way to invoke a
package's test suite.
Cheers,
-Barry
Attachment:
signature.asc
Description: PGP signature