Background
I have a repo for a new set of projects written in python. I have multi level folders set up to distinguish each tool when a developer checks out the repo. Something like the following:
repo
project1
__init__.py
project1
__init__.py
code
tests
__init__.py
test_something
project2
__init__.py
project2
__init__.py
code
tests
__init__.py
test_something
Problem
A developer gave me a pytest regression test script that executes all project unit tests in a given directory, however given my project structure it is unable to run. The driver cannot import any of the modules so the regression script fails immediately on Module errors.
I tried updating the project level init files with
import os, sys
for relativePath in ["/", "/..", "/../*, "/../tests"]:
fileLoc = os.path.dirname(os.path,realpath(os.path.abspath(__file__))) + relativePath
if( True == os.path.exists(fileLoc) and ( fileLoc not in sys.path) ):
sys.path.append(fileLoc)
but I don't believe that is going to be useful given the two folders per project.
Question
Is it possible to execute all unit tests at the "repo" level?
Would restructuring the repo be a better choice?