Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken: running individual python tests #45

Closed
springmeyer opened this issue Aug 26, 2015 · 10 comments
Closed

Broken: running individual python tests #45

springmeyer opened this issue Aug 26, 2015 · 10 comments
Assignees

Comments

@springmeyer
Copy link
Member

This used to work:

$ python test/python_tests/csv_test.py
Traceback (most recent call last):
  File "test/python_tests/csv_test.py", line 13, in <module>
    from .utilities import execution_path
ValueError: Attempted relative import in non-package

//cc @flippmoke @yohanboniface - any ideas?

@yohanboniface
Copy link
Member

Humm, yes, this cannot work, because we are doing a relative import (from .xxx).

We need that for python3 compat. I think the real answer of this issue is to have a real test runner instead of running them file by file. Do you want me to work on this?

@yohanboniface
Copy link
Member

But aren't we using nose? You should be able to limit the ran tests to this file passing arguments to nose.

@yohanboniface
Copy link
Member

@springmeyer python setup.py nosetests -w test/python_tests/csv_test.py ?

@springmeyer
Copy link
Member Author

Is this absolutely necessary for python3? Can't we support both 2 and 3 without breaking things?

@yohanboniface
Copy link
Member

Yes, it's absolutely necessary for python3: there is not way any more to make false relative import (i.e. import xxx where xxx is supposed to be relative).
By "breaking things", you mean that python path/to/test.py is not possible anymore? Is it a problem to replace with the line I pasted above?

@springmeyer
Copy link
Member Author

By "breaking things", you mean that python path/to/test.py is not possible anymore?

Correct. This is the way I run tests that I develop.

Is it a problem to replace with the line I pasted above?

Correct, its not sufficient. Running that is slower, not easy to remember, and outputs of bunch of noise:

running nosetests
running egg_info
writing mapnik.egg-info/PKG-INFO
writing top-level names to mapnik.egg-info/top_level.txt
writing dependency_links to mapnik.egg-info/dependency_links.txt
reading manifest file 'mapnik.egg-info/SOURCES.txt'
writing manifest file 'mapnik.egg-info/SOURCES.txt'
copying build/lib.macosx-10.10-x86_64-2.7/mapnik/_mapnik.so -> mapnik
/Library/Python/2.7/site-packages/nose/config.py:435: DeprecationWarning: Use of multiple -w arguments is deprecated and support may be removed in a future release. You can get the same behavior by passing directories without the -w argument on the command line, or by using the --tests argument in a configuration file.
  DeprecationWarning)

@yohanboniface
Copy link
Member

Running that is slower

How much slower? :) I see Ran 40 tests in 0.011s when I run it myself ;)

not easy to remember

Humm, would a Makefile entry help? Like make test path/to/file.py ?

outputs of bunch of noise

I'll see how to fix that.

@springmeyer
Copy link
Member Author

Another problem @yohanboniface. But certain files, when run from the command line, are meant to print more debugging info. For example main is overridden for test/python_tests/image_encoding_speed_test.py so that running it directly will print benchmarking info. This now no longer works because your proposed workaround of doing python setup.py nosetests -w test/python_tests/image_encoding_speed_test.py does not invoke main. This is quite frustrating for me because honestly python 3 support is much less important to me than trying to get things working and I'm loosing time hitting this whenever I try to run old scripts.

yohanboniface added a commit to yohanboniface/python-mapnik that referenced this issue Sep 24, 2015
Also make test/python_tests/image_encoding_speed_test.py compliant
with nosetest runner.
@yohanboniface
Copy link
Member

What about #53 ? :)

yohanboniface added a commit that referenced this issue Sep 24, 2015
Also make test/python_tests/image_encoding_speed_test.py compliant
with nosetest runner.
@lightmare
Copy link
Contributor

Running individual test module like this works:

cd test/
python -m python_tests.csv_test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants