1

I am the current maintainer of a biggish legacy wx python app. It was a community work and although had quite a bit of engineering thrown in, it was developed without any tests. I want to set up a testing repository to amend this situation so at least some critical parts of the code as well as new code can be developed with unit tests. My question is how to set up the test package. The code repository is structured as:

.git/
Mopy/
  bash/  # all the code is here
    package1/
    package2/
    ...
    module1.py
    module2.py
    ...

Seems simpler to have it in another repository - but how would I structure it ? How am I to import the classes to test ? Are there any standard conventions in python (as in src/test/java for maven) ?

I am familiar with JUnit etc - so this is not about how to write the tests - only about how to structure the testing package and importing the classes/bootstrapping it.

Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361
  • Have you read e.g. https://pytest.org/latest/goodpractises.html? – jonrsharpe Jan 09 '16 at 15:20
  • @jonrsharpe: no I wasn't aware - this link is broken btw. Nor did the duplicate question turn up in my search. I did read a bunch of other stuff but even in the duplicate question most people put the testing code with the packages to be tested which won't work in my case (we offer the code as a download and this is not quite user friendly - plus since the tests are a later addition and may require a whole lot of resources it would bloat the already bloated repo). Anyway I will have to look into the problem more and come back with something more specific. thanks :) – Mr_and_Mrs_D Jan 09 '16 at 18:47
  • pytest.org appears to be down, see cached: http://webcache.googleusercontent.com/search?q=cache:8akO72oweK0J:https://pytest.org/latest/goodpractises.html+&cd=1&hl=en&ct=clnk&gl=uk. If you want to do something unconventional, then asking about conventions won't help you much! – jonrsharpe Jan 09 '16 at 18:49
  • thanks - again same repo for tests and code - sigh :( – Mr_and_Mrs_D Jan 09 '16 at 18:51
  • Another option would be to make your code repo a [submodule](https://git-scm.com/docs/git-submodule) of the test repo, or just *install* the code (from e.g. PyPI) when you build and run the test repo. – jonrsharpe Jan 09 '16 at 19:02
  • I would like to avoid submodules for now (various reasons) and downloading the code would be an overkill as anyone who has the tests will have the code also. But don't get me wrong your suggestions are very valuable cause they help me define the problem - thanks :) Will go for a top level tests repo by the main one and see how that goes - but I have some bugfixing to attend to first :) – Mr_and_Mrs_D Jan 09 '16 at 19:10
  • @jonrsharpe: here is my current design (and woes): http://stackoverflow.com/q/40022220/281545 – Mr_and_Mrs_D Oct 13 '16 at 14:05

0 Answers0