In a message of Sun, 16 Aug 2015 18:45:31 +0100, Alan Gauld writes: >On 16/08/15 16:41, Alex Kleider wrote: > >>> - src the code >>> -- lang folder per language used - sql, python, C, bash, etc >>> --- lib modules/packages - subfolder per package >>> --- test test code - sub-tree under this, depends on test tools. >>> --- tools tools used but not shipped - db load/reset etc >>> --- main folder in some languages, a file in others >> >> Alan, >> Assuming the above structure and further assuming that your python test >> suite is under test, >> how do you arrange to import code that is under main? > >Thee are several options. >1) create links from, main to the test files needed >2) alter sys.path so imports can see the test folder >3) alter the PYTHONPATH environment var > >But in most of my Python projects main is a file rather than >a folder so test is "under" main anyway. This above is a generic >structure because most of my projects use 4 or 5 languages >at least. Some IDEs require different structures too so the >separate lang sub-structures may vary to suit the toolset usee. > >> I've not been able to do that. Is there a way? > >I suspect in this case the easiest solution is a link >(aka shortcut in windoze) >
We have a new mechanism for test discovery in 2.7 and 3.x https://docs.python.org/3/library/unittest.html see 26.3.3 It's been backported. see: https://pypi.python.org/pypi/unittest2 Also, if you are on Python2 and you put your tests in a test subdirectory you need to remember to make an __init__.py file there. Laura _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor