In my current project, I am developing a package.  It makes sense to embed
tests throughout the package's directory structure as they should be part
of the package & its distribution.  It may raise eyebrows that I have tests
sprinkled through various directories, but there are reasons for keeping
some tests in the same proximity as the modules needed to import data into
a database.  There are several directories importing data according to
different constraints.

The problem/annoyance I am facing is that tests need to access modules in
other directories, I have to play games at the beginning of each test file
which looks at os.path.realpath(__file__) to ascertain where the root of
the package can be found before calling os.path.append().  Since the
package is still under development, its structure is still in flux.  As a
result, any structural change requires that I re-adjust each test file
ensuring that the paths are still correct.

Here is the package's general structure:

+/package_directory/
       |
      +/data/
           + base_classes_used_by_some_tests.py
            |
           +/import_1/
            |    + test_code_requiring_base_classes_above.py
            |
           +/import_2/
            |     + different_test_code_requiring_base_classes_above.py
            |
           +/tests/
                  |
                 + more_test_code_requiring_base_classes_above.py

What is a better solution to minimize any tweaking forced upon the test
code?  It seems that formally installing the package will only remedy some
of the problems I am currently experiencing.

Any suggestions you may have will be very welcomed.

Jim
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to