Skip to content

Commit ceacfc6

Browse files
dhruvmanilacclauss
andauthored
Add algorithm for testing Project Euler solutions (#2471)
* Add file for testing Project Euler solutions * Remove the importlib import * Update project_euler/solution_test.py Co-authored-by: Christian Clauss <[email protected]> * Small tweaks to project_euler/solution_test.py * Test Project Euler solutions through Travis * Improved testing for Project Euler solutions: - Renamed file so that it isn't picked up by pytest - Fail fast on validating solutions through Travis CI * Update validate_solutions.py * Use namedtuple for input parameters and answer - Remove logging - Remove unnecessary checks for PROJECT_EULER_PATH as Travis CI picks up the same path * Fix flake8 errors: line too long * Small tweaks to validate_solutions.py * Add all answers & back to using dictionary * Using pytest for testing Project Euler solutions - As we want to fail fast on testing solutions, we need to test using this script first before we use tests written by the author. - As pytest stops testing as soon as it receives a traceback, we need to use pytest-subtests to tell pytest to test all the iterations for the function with given parameters. * Print error messages in oneline format * Separated answers into a separate file: - Add custom print function to print all the error messages at the end of all the tests - Let Travis skip if this failed Co-authored-by: Christian Clauss <[email protected]>
1 parent 187e8cc commit ceacfc6

File tree

3 files changed

+2972
-1
lines changed

3 files changed

+2972
-1
lines changed

Diff for: .travis.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ jobs:
1717
- mypy --ignore-missing-imports . || true # https://github.com/python/mypy/issues/7907
1818
- pytest --doctest-modules --ignore=project_euler/ --durations=10 --cov-report=term-missing:skip-covered --cov=. .
1919
- name: Project Euler
20-
before_script: pip install pytest-cov
20+
before_script:
21+
- pip install pytest-cov pytest-subtests
22+
- pytest --tb=no --no-summary --capture=no project_euler/validate_solutions.py || true # fail fast on wrong solution
2123
script:
2224
- pytest --doctest-modules --durations=10 --cov-report=term-missing:skip-covered --cov=project_euler/ project_euler/
2325
after_success:

0 commit comments

Comments
 (0)