Skip to content

Broken: running individual python tests #45

Description

@springmeyer

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?

Activity

  1. yohanboniface commented on Aug 26, 2015

    @yohanboniface
    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?

  2. yohanboniface commented on Aug 26, 2015

    @yohanboniface
    Member

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

  3. yohanboniface commented on Aug 26, 2015

    @yohanboniface
    Member

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

  4. springmeyer commented on Aug 27, 2015

    @springmeyer
    MemberAuthor

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

  5. yohanboniface commented on Aug 27, 2015

    @yohanboniface
    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?

  6. springmeyer commented on Aug 27, 2015

    @springmeyer
    MemberAuthor

    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)
    
  7. yohanboniface commented on Aug 27, 2015

    @yohanboniface
    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.

  8. springmeyer commented on Sep 23, 2015

    @springmeyer
    MemberAuthor

    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.

  9. yohanboniface commented on Sep 24, 2015

    @yohanboniface
    Member

    What about #53 ? :)

  10. lightmare commented on Aug 30, 2019

    @lightmare
    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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions