Closed judithabk6 closed 6 months ago
Sorry I don't understand the pb.
I don't understand why it does not work to go to the root of the repo and run pytest src/tests
(causal2023) [jabecass@marg039 med_bench]$ pytest src/tests
=========================================================================================== test session starts ============================================================================================
platform linux -- Python 3.7.5, pytest-7.1.2, pluggy-1.0.0
rootdir: /data/parietal/store/work/jabecass/med_bench
collected 0 items / 2 errors
================================================================================================== ERRORS ==================================================================================================
_______________________________________________________________________ ERROR collecting src/tests/estimation/test_get_estimation.py _______________________________________________________________________
ImportError while importing test module '/data/parietal/store/work/jabecass/med_bench/src/tests/estimation/test_get_estimation.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../miniconda3/envs/causal2023/lib/python3.7/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
src/tests/estimation/test_get_estimation.py:19: in <module>
from med_bench.get_simulated_data import simulate_data
E ModuleNotFoundError: No module named 'med_bench'
___________________________________________________________________ ERROR collecting src/tests/simulate_data/test_get_simulated_data.py ____________________________________________________________________
ImportError while importing test module '/data/parietal/store/work/jabecass/med_bench/src/tests/simulate_data/test_get_simulated_data.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../miniconda3/envs/causal2023/lib/python3.7/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
src/tests/simulate_data/test_get_simulated_data.py:21: in <module>
from med_bench.get_simulated_data import simulate_data
E ModuleNotFoundError: No module named 'med_bench'
========================================================================================= short test summary info ==========================================================================================
ERROR src/tests/estimation/test_get_estimation.py
ERROR src/tests/simulate_data/test_get_simulated_data.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================================================ 2 errors in 1.06s =============================================================================================
(causal2023) [jabecass@marg039 med_bench]$ PYTHONPATH=src pytest src/tests
=========================================================================================== test session starts ============================================================================================
platform linux -- Python 3.7.5, pytest-7.1.2, pluggy-1.0.0
rootdir: /data/parietal/store/work/jabecass/med_bench
collected 976 items
src/tests/estimation/test_get_estimation.py ......................................ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssss..ssssssEE........FFssss.........................
it's not that big of a problem, but I am not sure what the right behavior is
But if you just launch pytest
at the root of the repo, it works. Doesnt'it ?
yes! you're right
Unfortunately it does not work from my side even if I go the root of the repo...
`(base) MAC-11108352:med_bench hzenati$ pytest ============================= test session starts ============================== platform darwin -- Python 3.11.5, pytest-7.4.0, pluggy-1.0.0 rootdir: /Users/hzenati/Documents/Work/causal inference/med_bench plugins: anyio-3.5.0 collected 0 items / 2 errors
==================================== ERRORS ====================================
_ ERROR collecting src/tests/estimation/test_getestimation.py
ImportError while importing test module '/Users/hzenati/Documents/Work/causal inference/med_bench/src/tests/estimation/test_get_estimation.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../../../anaconda3/lib/python3.11/importlib/init.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
src/tests/estimation/test_get_estimation.py:19: in
==================================== ERRORS ====================================
_ ERROR collecting src/tests/estimation/test_getestimation.py
ImportError while importing test module '/Users/hzenati/Documents/Work/causal inference/med_bench/src/tests/estimation/test_get_estimation.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../../../anaconda3/lib/python3.11/importlib/init.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
src/tests/estimation/test_get_estimation.py:19: in
On which branch ?
Have you run pip install -e .
on the module ?
I was working in my own renaming_modules branch, but indeed the command you suggested made everything work! thanks for this help.
Out of curiosity, what does the command pip install -e .
do more than the python setup.py install
command? should we add it in the Read.me file as well for the installation ??
It just makes it explicit that the install path is the local path.
Hi @judithabk6 , @bthirion , I think we can close this issue ?
Closing for now.
PYTHONPATH=src pytest src/tests
to run the tests, not sure what the fix is