I have written a test runner tool that's supposed to import files with tests in them, run them in a specific order or not and report results.
my setup is something like this:
somewhere/my_script.py
...
module/source/module_main.py
module/tests/some_data.py
module/tests/test_module.py
The code to import things looks like this:
for entry in os.listdir():
entry = entry[:-3]
spec = importlib.util.spec_from_file_location(entry, f"./{entry}.py")
my_module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(my_module)
if I run my_script via command line in module/tests to run test_module, Importing module_main works. Importing some_data does not.
I'm getting a ModuleNotFoundError even though it's right there.
I'm not sure how I can fix that.