I cannot run the test cases because they contain import statements that refer to src.metacast, and while src/ is a directory it isn't a valid Python module:
$ python3 tests/test_event_que.py
Traceback (most recent call last):
File "/home/.../MetaCast/tests/test_event_que.py", line 9, in <module>
from src.metacast import MetaCaster
ModuleNotFoundError: No module named 'src'
If I replace src.metacast with metacast, I can run all of the test cases in a virtual environment where I have installed MetaCast, and they all succeed.
Creating a virtual environment (e.g., in ./venv) and installing MetaCast is relatively straightforward, and the following could be saved as a shell script (e.g., run_tests.sh):
$ python3 -m venv ./venv
$ . venv/bin/activate
$ pip install .
$ for test_file in tests/test_*.py; do python3 "${test_file}"; done
....
----------------------------------------------------------------------
Ran 4 tests in 0.553s
OK
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
.
----------------------------------------------------------------------
Ran 1 test in 0.960s
OK
........
----------------------------------------------------------------------
Ran 8 tests in 0.259s
OK
NOTE: In the rest of this comment, I provide a suggestion about how to automate the test cases. I do not expect you to implement this kind of automation as a necessary step in the JOSS review process. This is just a suggestion for your consideration, entirely independent of my comments for the JOSS review.
Alternatively, you could consider using an automation tool. For example, I use nox for running test cases, building and publishing online documentation, running code checks, etc. To run the MetaCast test cases with nox, you can create a file called noxfile.py with the following content:
import nox
import pathlib
@nox.session(reuse_venv=True)
def tests(session):
"""Run test cases."""
session.install('.')
test_dir = pathlib.Path('tests')
for test_file in test_dir.glob('test_*.py'):
session.run('python3', test_file)
If you install nox, you can then run it from the root of the repository to run the test cases:
$ nox
nox > Running session tests
nox > Creating virtual environment (virtualenv) using python3 in .nox/tests
nox > python -m pip install .
nox > python3 tests/test_event_que.py
....
----------------------------------------------------------------------
Ran 4 tests in 0.610s
OK
nox > python3 tests/test_metacaster.py
........
----------------------------------------------------------------------
Ran 8 tests in 0.263s
OK
nox > python3 tests/test_lhs_and_prcc.py
.
----------------------------------------------------------------------
Ran 1 test in 1.014s
OK
nox > python3 tests/test_infection_seeding.py
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
nox > Session tests was successful.
You could then add a GitHub workflow that installs Python, then installs and runs nox.
Hi @m-d-grunnill
I cannot run the test cases because they contain import statements that refer to
src.metacast
, and whilesrc/
is a directory it isn't a valid Python module:If I replace
src.metacast
withmetacast
, I can run all of the test cases in a virtual environment where I have installedMetaCast
, and they all succeed.Creating a virtual environment (e.g., in
./venv
) and installingMetaCast
is relatively straightforward, and the following could be saved as a shell script (e.g.,run_tests.sh
):NOTE: In the rest of this comment, I provide a suggestion about how to automate the test cases. I do not expect you to implement this kind of automation as a necessary step in the JOSS review process. This is just a suggestion for your consideration, entirely independent of my comments for the JOSS review.
Alternatively, you could consider using an automation tool. For example, I use nox for running test cases, building and publishing online documentation, running code checks, etc. To run the
MetaCast
test cases withnox
, you can create a file callednoxfile.py
with the following content:If you install
nox
, you can then run it from the root of the repository to run the test cases:You could then add a GitHub workflow that installs Python, then installs and runs
nox
.