Skip to content

Commit a60c071

Browse files
batch error logs (#484)
Category: feature JIRA issue: MIC-5503 Add with checks. Testing Added multiple assert statements that would fail using with check and verified that they all appeared in the output logs.
1 parent e313609 commit a60c071

File tree

7 files changed

+26
-12
lines changed

7 files changed

+26
-12
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ jobs:
5656
cd pseudopeople
5757
echo "Contents of install_dependency_branch.sh"
5858
echo "----------------------------------------"
59-
cat ../vivarium_build_utils/install_dependency_branch.sh
59+
cat ../vivarium_build_utils/resources/scripts/install_dependency_branch.sh
6060
echo ""
6161
echo "----------------------------------------"
62-
sh ../vivarium_build_utils/install_dependency_branch.sh layered_config_tree ${branch_name} github
62+
sh ../vivarium_build_utils/resources/scripts/install_dependency_branch.sh layered_config_tree ${branch_name} github
6363
- name: print environment values
6464
run: |
6565
cat $GITHUB_ENV

.readthedocs.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ python:
1919
# Doc builds will fail if there are any warnings
2020
sphinx:
2121
fail_on_warning: true
22+
configuration: docs/source/conf.py
2223

2324
formats:
2425
- pdf

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ exclude = [
2323
[[tool.mypy.overrides]]
2424
module = [
2525
"scipy.*",
26+
"pytest_check",
2627
]
2728
ignore_missing_imports = true

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"tqdm",
5151
"layered_config_tree>=2.1.0",
5252
"loguru",
53+
"pytest_check",
5354
# type stubs
5455
"pandas-stubs",
5556
"types-PyYAML",

tests/integration/release/test_release.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pandas as pd
66
import pytest
77
from _pytest.fixtures import FixtureRequest
8+
from pytest_check import check
89
from vivarium_testing_utils import FuzzyChecker
910

1011
from pseudopeople.dataset import Dataset

tests/integration/release/test_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
)
2020
def test_release_tests(pytest_args: list[str]) -> None:
2121
os.chdir(Path(__file__).parent) # need this to access cli options from conftest.py
22-
base_cmd = ["pytest", "--release", "test_release.py"]
22+
base_cmd = ["pytest", "--release", "test_release.py", "--check-max-tb=1000"]
2323
cmd = base_cmd + pytest_args
2424
result = subprocess.run(cmd, capture_output=True, text=True)
2525
assert result.returncode == 0

tests/utilities.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import numpy as np
99
import numpy.typing as npt
1010
import pandas as pd
11+
from pytest_check import check
1112
from vivarium_testing_utils import FuzzyChecker
1213

1314
from pseudopeople.configuration import Keys, get_configuration
@@ -34,7 +35,8 @@ def run_column_noising_tests(
3435

3536
# Check that originally missing data remained missing
3637
originally_missing_idx = check_original.index[check_original[col.name].isna()]
37-
assert check_noised.loc[originally_missing_idx, col.name].isna().all()
38+
with check:
39+
assert check_noised.loc[originally_missing_idx, col.name].isna().all()
3840

3941
# Check for noising where applicable
4042
to_compare_idx = shared_idx.difference(originally_missing_idx)
@@ -43,7 +45,8 @@ def run_column_noising_tests(
4345
check_original.loc[to_compare_idx, col.name].values
4446
!= check_noised.loc[to_compare_idx, col.name].values
4547
)
46-
assert different_check.any()
48+
with check:
49+
assert different_check.any()
4750

4851
noise_level = different_check.sum()
4952

@@ -64,7 +67,8 @@ def run_column_noising_tests(
6467
== check_noised.loc[to_compare_idx, col.name].values
6568
)
6669

67-
assert same_check.all()
70+
with check:
71+
assert same_check.all()
6872

6973

7074
def run_omit_row_or_do_not_respond_tests(
@@ -87,15 +91,20 @@ def run_omit_row_or_do_not_respond_tests(
8791
]:
8892
# Census and household surveys have do_not_respond and omit_row.
8993
# For all other datasets they are mutually exclusive
90-
assert len(noise_types) == 2
94+
with check:
95+
assert len(noise_types) == 2
9196
else:
92-
assert len(noise_types) < 2
97+
with check:
98+
assert len(noise_types) < 2
9399
if not noise_types: # Check that there are no missing indexes
94-
assert noised_data.index.symmetric_difference(original_data.index).empty
100+
with check:
101+
assert noised_data.index.symmetric_difference(original_data.index).empty
95102
else: # Check that there are some omissions
96103
# TODO: assert levels are as expected
97-
assert noised_data.index.difference(original_data.index).empty
98-
assert not original_data.index.difference(noised_data.index).empty
104+
with check:
105+
assert noised_data.index.difference(original_data.index).empty
106+
with check:
107+
assert not original_data.index.difference(noised_data.index).empty
99108

100109

101110
def validate_column_noise_level(
@@ -158,7 +167,8 @@ def validate_column_noise_level(
158167
[1 - p for p in token_probability]
159168
)
160169
else:
161-
assert isinstance(tokens_per_string, pd.Series)
170+
with check:
171+
assert isinstance(tokens_per_string, pd.Series)
162172
avg_probability_any_token_noised = (
163173
1 - (1 - token_probability) ** tokens_per_string
164174
).mean()

0 commit comments

Comments
 (0)