Open GoogleCodeExporter opened 8 years ago
To elaborate, there are a few other workarounds. They each have some problems.
One is that you can make a custom 2to3 builder that puts compiled test files
into build/tests/. Then tox.ini or your test runner can specify that path to
run tests in. This is how Nose does it:
https://bitbucket.org/jpellerin/nose/src/734bc7bc40ab/selftest.py#cl-35
The drawback is you need to use a custom 2to3 builder.
Another way is to run all your tests via import. For example, run your tests
as:
test_runnner mymodule.tests.py3k_suite
This is how Fudge does it:
https://bitbucket.org/kumar303/fudge/src/9cafce359a21/tox.ini#cl-26
Pretty lame and error prone.
A more direct way is to use a custom test runner that gets the build test path
at runtime:
import os
import PyHamcrest.tests
testdir = os.path.dirname(PyHamcrest.tests.__file__)
# eg. /prefix/lib/python3.1/site-packages/PyHamcrest-1.4-py3.1.egg/tests
run_tests(testdir)
Original comment by kumar.mcmillan
on 17 Feb 2011 at 9:27
do i assume right that both of you have projects that have tests inlined?
For projects that have tests living within the application package the tests
usually get converted during setup/2to3, i guess. Maybe Tox could then help
with converting command line arguments (i.e. test locations) in some way.
For projects having tests outside the application package we probably need some
support for a "copy-tests" step which would copy the tests to some per-env
directory and could optionally invoke some (2to3) conversion script.
If anybody has any more thoughts or concrete considerations let me know. I
will not get to implement such a feature myself soon i think.
Original comment by holger.k...@gmail.com
on 1 Mar 2011 at 4:36
I've used both packaged tests and non packaged tests. Both approaches seem to
have problems. Is there really not a better way? I feel like I'm missing it
somehow. Does everyone just develop single source modules without the need for
2to3? I know Michael's mock is single source for 2.4 - 3.x
But, yeah, I guess one solution would be to provide access to a build dir or
deployment dir as a tox.ini variable. Then the tests could cd into that and
run the discovery script.
Original comment by kumar.mcmillan
on 1 Mar 2011 at 5:49
Original issue reported on code.google.com by
off...@offby1.net
on 17 Feb 2011 at 9:12