Skip to content

Commit

Permalink
Add algorithm for testing Project Euler solutions (#2471)
Browse files Browse the repository at this point in the history
* Add file for testing Project Euler solutions

* Remove the importlib import

* Update project_euler/solution_test.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* 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 <cclauss@me.com>
  • Loading branch information
dhruvmanila and cclauss authored Sep 28, 2020
1 parent 187e8cc commit ceacfc6
Show file tree
Hide file tree
Showing 3 changed files with 2,972 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ jobs:
- mypy --ignore-missing-imports . || true # https://github.com/python/mypy/issues/7907
- pytest --doctest-modules --ignore=project_euler/ --durations=10 --cov-report=term-missing:skip-covered --cov=. .
- name: Project Euler
before_script: pip install pytest-cov
before_script:
- pip install pytest-cov pytest-subtests
- pytest --tb=no --no-summary --capture=no project_euler/validate_solutions.py || true # fail fast on wrong solution
script:
- pytest --doctest-modules --durations=10 --cov-report=term-missing:skip-covered --cov=project_euler/ project_euler/
after_success:
Expand Down
Loading

0 comments on commit ceacfc6

Please sign in to comment.