Skip to content

Commit 24c830c

Browse files
authored
Start running validate_solutions script for Travis CI (TheAlgorithms#3215)
* Removed print error_msgs at the end of test: This was done only to reduce the message clutter produced by 60 failing tests. As that is fixed, we can produce the traceback in short form and allow pytest to print the captured error message output at the end of test. * Start validate_solutions script for Travis CI I am separating out the solution testing and doctest as validating the solutions for the current number of solutions present is taking 2 minutes to run.
1 parent 7a44f16 commit 24c830c

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

Diff for: .travis.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ jobs:
1212
- pytest --doctest-modules --ignore=project_euler/ --durations=10 --cov-report=term-missing:skip-covered --cov=. .
1313
- name: Project Euler
1414
install:
15-
- pip install pytest-cov pytest-subtests
16-
before_script:
17-
- pytest --tb=no --no-summary --capture=no project_euler/validate_solutions.py || true # fail fast on wrong solution
15+
- pip install pytest-cov
1816
script:
1917
- pytest --doctest-modules --durations=10 --cov-report=term-missing:skip-covered --cov=project_euler/ project_euler/
18+
- name: Project Euler Solution
19+
install:
20+
- pip install pytest-subtests
21+
script:
22+
- pytest --tb=short project_euler/validate_solutions.py
2023
after_success:
2124
- scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md
2225
notifications:

Diff for: project_euler/validate_solutions.py

+3-16
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
with open(PROJECT_EULER_ANSWERS_PATH) as file_handle:
1616
PROBLEM_ANSWERS = json.load(file_handle)
1717

18-
error_msgs = []
19-
2018

2119
def generate_solution_modules(
2220
dir_path: pathlib.Path,
@@ -48,20 +46,9 @@ def test_project_euler(subtests, problem_number: int, expected: str):
4846
answer = str(solution_module.solution())
4947
assert answer == expected, f"Expected {expected} but got {answer}"
5048
except (AssertionError, AttributeError, TypeError) as err:
51-
error_msgs.append(
52-
f"problem_{problem_number}/{solution_module.__name__}: {err}"
49+
print(
50+
f"problem_{problem_number:02}/{solution_module.__name__}: {err}"
5351
)
54-
raise # We still want pytest to know that this test failed
52+
raise
5553
else:
5654
pytest.skip(f"Solution {problem_number} does not exist yet.")
57-
58-
59-
# Run this function at the end of all the tests
60-
# https://stackoverflow.com/a/52873379
61-
@pytest.fixture(scope="session", autouse=True)
62-
def custom_print_message(request):
63-
def print_error_messages():
64-
if error_msgs:
65-
print("\n" + "\n".join(error_msgs))
66-
67-
request.addfinalizer(print_error_messages)

0 commit comments

Comments
 (0)