This document describes unit tests for the Python module and how to run them with the current project structure.
The guide applies to the folder structure:
Python/tests/- test files and fixturesPython/run_tests.bat- Windows helper scriptPython/run_tests.sh- Linux/macOS helper scriptPython/run_tests_coverage.bat- Windows coverage script
Unit tests are located in Python/tests/:
test_job.pytest_machine.pytest_schedule.pytest_greedy.pytest_tabu_search.pytest_branch_and_bound.pytest_gantt_chart.pytest_main.pyconftest.py(shared fixtures)
- Python 3.8+
- Install runtime dependencies:
cd Python
pip install -r requirements.txt- Install test dependencies:
pip install -r tests/requirements-test.txtNote: test requirements are currently stored in tests/requirements-test.txt.
Run from the Python/ directory.
python -m pytest tests -v --tb=shortpython -m pytest tests/test_schedule.py -vpython -m pytest tests/test_tabu_search.py::TestTabuSearch -vpython -m pytest tests/test_job.py::TestJobInitialization::test_job_creation_with_valid_data -vpython -m pytest tests -x -vpython -m pytest tests -v --capture=nocd Python
run_tests.batWith custom arguments:
run_tests.bat tests/test_main.py -vcd Python
chmod +x run_tests.sh
./run_tests.shcd Python
run_tests_coverage.batpython -m pytest tests \
--cov=core \
--cov=algorithms \
--cov=utils \
--cov=main \
--cov-report=term-missing \
--cov-report=htmlHTML report is generated in Python/htmlcov/index.html.
- Run all tests:
python -m pytest tests -v- Run coverage for core modules:
python -m pytest tests --cov=core --cov=algorithms --cov=utils --cov-report=term-missing- If changing CLI behavior in
main.py, run:
python -m pytest tests/test_main.py -v --capture=nopip install -r tests/requirements-test.txtpip install pytest-cov- Ensure you run commands from
Python/. - Prefer
python -m pytest ...over plainpytest.
- Use mocked tests from
test_gantt_chart.py. - Avoid forcing GUI backends for matplotlib.
- Existing helper scripts still print install hints for
requirements-test.txtin the module root. - In the current structure, the active file is
tests/requirements-test.txt.