You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently have to do: nosetests-2.7 test_analysis.py:Test_Helanal
and not: nosetests-2.7 test_analysis:Test_Helanal
because of a relative import problem. Since the wiki docs advertise the version
without the .py, it is perhaps suitable to have a consistent policy on whether
we will allow Python relative imports in unit test modules. It seems that we
can mostly work around relative imports, except for things that were placed in
the testing __init__.py
Original issue reported on code.google.com by tyler.je.reddy@gmail.com on 8 Jul 2014 at 7:39
This is a tricky one. It is also worth noting that the wiki indicates that one can invoke all the tests from the command line at the path MDAnalysis/tests by typing nosetests, but this is not the case for me, at least on OS X, even if specifying the --exe flag.
Perhaps that was written before the tests were placed in a separate package? In any case, it seems that the direct command line invocation of nosetests is most appropriately performed at the /testsuite/MDAnalysisTests path, so the wiki should probably be updated to reflect that (shall I open a separate issue for that?).
There are various blog posts and stackoverflow threads about the original issue discussed in this thread. They are mostly focused on invoking python with the -m flag or altering package __init__.py and __all__ structures. I'll see what I can do about it.
Perhaps that was written before the tests were placed in a separate package? In any case, it seems that the direct command line invocation of nosetests is most appropriately performed at the/testsuite/MDAnalysisTests path, so the wiki should probably be updated to reflect that (shall I open a separate issue for that?).
Just update the wiki to reflect what currently works.
If you (or anyone else) feels the other way should work, raise an issue.
So the way Travis runs tests is just running nosetests from the root of the repo (one up from either package or testsuite), I've just checked and this works for me from ubuntu. Could just be an OSX quirk?
Relative imports are now banned in all MDAnalysis unit testing modules, and have been replaced accordingly. A new testing module will cause the unit testing suite to issue a FAIL if any module contains a line of code with 'from .' and 'import' strings. By substituting the absolute import statements in place of the relative import statements individual tests can now be performed using either of the call signatures originally described in this issue without problems. Absolute imports are also arguably more clear / explicit. So, I'm closing this issue.
Yes, you may run nosetests from the root of the repo or from /testsuite/MDAnalysisTests, but the method on the wiki no longer seems to work.
Activity
orbeckst commentedon May 24, 2015
I'd like to have a consistent policy on how to run the tests.
tylerjereddy commentedon Jun 14, 2015
This is a tricky one. It is also worth noting that the wiki indicates that one can invoke all the tests from the command line at the path
MDAnalysis/testsby typingnosetests, but this is not the case for me, at least on OS X, even if specifying the--exeflag.Perhaps that was written before the tests were placed in a separate package? In any case, it seems that the direct command line invocation of
nosetestsis most appropriately performed at the/testsuite/MDAnalysisTestspath, so the wiki should probably be updated to reflect that (shall I open a separate issue for that?).There are various blog posts and stackoverflow threads about the original issue discussed in this thread. They are mostly focused on invoking python with the
-mflag or altering package__init__.pyand__all__structures. I'll see what I can do about it.orbeckst commentedon Jun 14, 2015
Hi Tyler,
On 14 Jun, 2015, at 01:36, Tyler Reddy wrote:
Just update the wiki to reflect what currently works.
If you (or anyone else) feels the other way should work, raise an issue.
Thanks,
Oliver
richardjgowers commentedon Jun 14, 2015
So the way Travis runs tests is just running
nosetestsfrom the root of the repo (one up from eitherpackageortestsuite), I've just checked and this works for me from ubuntu. Could just be an OSX quirk?-added new test_imports.py module to enforce the ban on relative impo…
Updated CHANGELOG to reflect resolution of Issue #189.
tylerjereddy commentedon Jun 15, 2015
Relative imports are now banned in all MDAnalysis unit testing modules, and have been replaced accordingly. A new testing module will cause the unit testing suite to issue a FAIL if any module contains a line of code with 'from .' and 'import' strings. By substituting the absolute import statements in place of the relative import statements individual tests can now be performed using either of the call signatures originally described in this issue without problems. Absolute imports are also arguably more clear / explicit. So, I'm closing this issue.
Yes, you may run
nosetestsfrom the root of the repo or from/testsuite/MDAnalysisTests, but the method on the wiki no longer seems to work.Remove relative imports introduced in MDAnalysis#787