diff --git a/python_tool_competition_2024/templates/targets/sub_example/example4.py b/python_tool_competition_2024/templates/targets/sub_example/example4.py new file mode 100644 index 0000000..f8cf323 --- /dev/null +++ b/python_tool_competition_2024/templates/targets/sub_example/example4.py @@ -0,0 +1,23 @@ +import gzip + +def compress_string(s): + """ + Compress a string using gzip. + + :param s: String to be compressed + :type s: str + :return: Compressed string + :rtype: bytes + """ + return gzip.compress(s.encode('utf-8')) + +def decompress_string(compressed): + """ + Decompress a gzipped string. + + :param compressed: Compressed string + :type compressed: bytes + :return: Decompressed string + :rtype: str + """ + return gzip.decompress(compressed).decode('utf-8') diff --git a/tests/calculation/mutation_calculator/test_cosmic_ray_calculator.py b/tests/calculation/mutation_calculator/test_cosmic_ray_calculator.py index d13a800..cdd9a69 100644 --- a/tests/calculation/mutation_calculator/test_cosmic_ray_calculator.py +++ b/tests/calculation/mutation_calculator/test_cosmic_ray_calculator.py @@ -42,6 +42,7 @@ def test_cosmic_ray_calculator(tmp_path: Path) -> None: "example2": RatioResult(11, 1), "sub_example": RatioResult(12, 2), "sub_example.example3": RatioResult(13, 3), + "sub_example.example4": RatioResult(14, 4), } assert run_command_mock.call_args_list == [ @@ -49,6 +50,7 @@ def test_cosmic_ray_calculator(tmp_path: Path) -> None: *_cr_calls(config, "example2"), *_cr_calls(config, "sub_example"), *_cr_calls(config, "sub_example.example3"), + *_cr_calls(config, "sub_example.example4"), ] cr_path = tmp_path / "dummy" / "cosmic_ray" assert { @@ -67,6 +69,10 @@ def test_cosmic_ray_calculator(tmp_path: Path) -> None: TARGETS_DIR / "sub_example" / "example3.py", None ), cr_path + / "sub_example.example4.toml": _cr_config( + TARGETS_DIR / "sub_example" / "example4.py", None + ), + cr_path / "sub_example.toml": _cr_config( TARGETS_DIR / "sub_example" / "__init__.py", None ), @@ -101,6 +107,7 @@ def test_cosmic_ray_calculator_with_failing_baseline(tmp_path: Path) -> None: "example2": RatioResult(11, 1), "sub_example": RatioResult(12, 2), "sub_example.example3": RatioResult(13, 3), + "sub_example.example4": RatioResult(14, 4), } assert tuple(capture.get().splitlines()) == tuple( ( @@ -112,6 +119,7 @@ def test_cosmic_ray_calculator_with_failing_baseline(tmp_path: Path) -> None: "example2", "sub_example", "sub_example.example3", + "sub_example.example4", ) ) @@ -120,6 +128,7 @@ def test_cosmic_ray_calculator_with_failing_baseline(tmp_path: Path) -> None: *_cr_calls(config, "example2", skip_exec=True), *_cr_calls(config, "sub_example", skip_exec=True), *_cr_calls(config, "sub_example.example3", skip_exec=True), + *_cr_calls(config, "sub_example.example4", skip_exec=True), ] @@ -149,6 +158,7 @@ def test_cosmic_ray_calculator_with_failing_baseline_and_output(tmp_path: Path) "example2": RatioResult(11, 1), "sub_example": RatioResult(12, 2), "sub_example.example3": RatioResult(13, 3), + "sub_example.example4": RatioResult(14, 4), } assert tuple(capture.get().splitlines()) == tuple( f"Could not run mutation testing for {module}." @@ -157,6 +167,7 @@ def test_cosmic_ray_calculator_with_failing_baseline_and_output(tmp_path: Path) "example2", "sub_example", "sub_example.example3", + "sub_example.example4", ) ) @@ -165,6 +176,7 @@ def test_cosmic_ray_calculator_with_failing_baseline_and_output(tmp_path: Path) *_cr_calls(config, "example2", skip_exec=True), *_cr_calls(config, "sub_example", skip_exec=True), *_cr_calls(config, "sub_example.example3", skip_exec=True), + *_cr_calls(config, "sub_example.example4", skip_exec=True), ] diff --git a/tests/calculation/mutation_calculator/test_mutpy_calculator.py b/tests/calculation/mutation_calculator/test_mutpy_calculator.py index fede6d5..c7de402 100644 --- a/tests/calculation/mutation_calculator/test_mutpy_calculator.py +++ b/tests/calculation/mutation_calculator/test_mutpy_calculator.py @@ -41,6 +41,7 @@ def test_mutpy_calculator(tmp_path: Path) -> None: "example2": RatioResult(11, 1), "sub_example": RatioResult(12, 2), "sub_example.example3": RatioResult(13, 3), + "sub_example.example4": RatioResult(14, 4), } assert run_command_mock.call_args_list == [ @@ -52,6 +53,7 @@ def test_mutpy_calculator(tmp_path: Path) -> None: ), _mutpy_call(config, TARGETS_DIR / "sub_example" / "__init__.py", None), _mutpy_call(config, TARGETS_DIR / "sub_example" / "example3.py", None), + _mutpy_call(config, TARGETS_DIR / "sub_example" / "example4.py", None), ] @@ -88,6 +90,7 @@ def test_mutpy_calculator_always_failing(tmp_path: Path) -> None: _mutpy_call(config, TARGETS_DIR / "example2.py", None), _mutpy_call(config, TARGETS_DIR / "sub_example" / "__init__.py", None), _mutpy_call(config, TARGETS_DIR / "sub_example" / "example3.py", None), + _mutpy_call(config, TARGETS_DIR / "sub_example" / "example4.py", None), ] @@ -118,6 +121,7 @@ def test_mutpy_calculator_failing(tmp_path: Path) -> None: "example2": RatioResult(11, 1), "sub_example": RatioResult(12, 2), "sub_example.example3": RatioResult(13, 3), + "sub_example.example4": RatioResult(14, 4), } assert tuple(capture.get().splitlines()) == tuple( @@ -139,6 +143,7 @@ def test_mutpy_calculator_failing(tmp_path: Path) -> None: _mutpy_call(config, TARGETS_DIR / "example2.py", None), _mutpy_call(config, TARGETS_DIR / "sub_example" / "__init__.py", None), _mutpy_call(config, TARGETS_DIR / "sub_example" / "example3.py", None), + _mutpy_call(config, TARGETS_DIR / "sub_example" / "example4.py", None), ] @@ -169,6 +174,7 @@ def test_mutpy_calculator_failing_with_output(tmp_path: Path) -> None: "example2": RatioResult(11, 1), "sub_example": RatioResult(12, 2), "sub_example.example3": RatioResult(13, 3), + "sub_example.example4": RatioResult(14, 4), } assert tuple(capture.get().splitlines()) == tuple( @@ -187,6 +193,7 @@ def test_mutpy_calculator_failing_with_output(tmp_path: Path) -> None: _mutpy_call(config, TARGETS_DIR / "example2.py", None), _mutpy_call(config, TARGETS_DIR / "sub_example" / "__init__.py", None), _mutpy_call(config, TARGETS_DIR / "sub_example" / "example3.py", None), + _mutpy_call(config, TARGETS_DIR / "sub_example" / "example4.py", None), ] @@ -239,6 +246,7 @@ def test_mutpy_calculator_failing_with_wrong_numbers(tmp_path: Path) -> None: ), _mutpy_call(config, TARGETS_DIR / "sub_example" / "__init__.py", None), _mutpy_call(config, TARGETS_DIR / "sub_example" / "example3.py", None), + _mutpy_call(config, TARGETS_DIR / "sub_example" / "example4.py", None), ] diff --git a/tests/cli/helpers.py b/tests/cli/helpers.py index 9bdf5cc..f578668 100644 --- a/tests/cli/helpers.py +++ b/tests/cli/helpers.py @@ -152,6 +152,7 @@ def _register_generators( RatioResult(50, 1), RatioResult(1, 1), RatioResult(49, 0), + RatioResult(49, 0), ) _COVERAGES = ( @@ -159,6 +160,7 @@ def _register_generators( Coverages(RatioResult(3, 0), RatioResult(8, 2)), Coverages(RatioResult(7, 7), RatioResult(12, 6)), Coverages(RatioResult(20, 5), RatioResult(25, 16)), + Coverages(RatioResult(20, 5), RatioResult(25, 16)), ) diff --git a/tests/cli/test_init.py b/tests/cli/test_init.py index 092aaa1..5099c29 100644 --- a/tests/cli/test_init.py +++ b/tests/cli/test_init.py @@ -43,6 +43,7 @@ "sub_example": { "__init__.py": (TARGETS_DIR / "sub_example" / "__init__.py").read_text(), "example3.py": (TARGETS_DIR / "sub_example" / "example3.py").read_text(), + "example4.py": (TARGETS_DIR / "sub_example" / "example4.py").read_text(), }, } diff --git a/tests/cli/test_run.py b/tests/cli/test_run.py index da6d767..0ad94cd 100644 --- a/tests/cli/test_run.py +++ b/tests/cli/test_run.py @@ -32,8 +32,9 @@ def test_run_in_wd(wd_tmp_path: Path) -> None: │ example2.py │ ✖ │ 0.00 % │ 25.00 % │ 2.00 % │ │ sub_example/__init__.py │ ✔ │ 100.00 % │ 50.00 % │ 100.00 % │ │ sub_example/example3.py │ ✔ │ 25.00 % │ 64.00 % │ 0.00 % │ +│ sub_example/example4.py │ ✔ │ 25.00 % │ 64.00 % │ 0.00 % │ ├─────────────────────────┼─────────┼───────────────┼─────────────────┼────────────────┤ -│ Total │ 50.00 % │ 42.50 % │ 50.00 % │ 21.00 % │ +│ Total │ 60.00 % │ 36.67 % │ 54.12 % │ 16.87 % │ └─────────────────────────┴─────────┴───────────────┴─────────────────┴────────────────┘ """.splitlines(), ) @@ -44,6 +45,7 @@ def test_run_in_wd(wd_tmp_path: Path) -> None: test_dir / "__init__.py", test_dir / "sub_example" / "__init__.py", test_dir / "sub_example" / "test_example3.py", + test_dir / "sub_example" / "test_example4.py", test_dir / "test_sub_example.py", ) csv_file = results_dir / "statistics.csv" @@ -54,6 +56,7 @@ def test_run_in_wd(wd_tmp_path: Path) -> None: wd_tmp_path / "targets" / "example2.py", wd_tmp_path / "targets" / "sub_example" / "__init__.py", wd_tmp_path / "targets" / "sub_example" / "example3.py", + wd_tmp_path / "targets" / "sub_example" / "example4.py", ) assert tuple(csv_file.read_text().splitlines()) == ( ( @@ -67,10 +70,12 @@ def test_run_in_wd(wd_tmp_path: Path) -> None: "example2.py,0.0,1,0,0.0,3,0,0.25,8,2,0.02,50,1", "sub_example/__init__.py,1.0,1,1,1.0,7,7,0.5,12,6,1.0,1,1", "sub_example/example3.py,1.0,1,1,0.25,20,5,0.64,25,16,0.0,49,0", - "total,0.5,4,2,0.425,40,17,0.5,60,30,0.21,200,42", + "sub_example/example4.py,1.0,1,1,0.25,20,5,0.64,25,16,0.0,49,0", + "total,0.6,5,3,0.36666666666666664,60,22,0.5411764705882353,85,46,0.1686746987951807,249,42", ) targets = ( targets_dir / "sub_example" / "example3.py", + targets_dir / "sub_example" / "example4.py", targets_dir / "sub_example" / "__init__.py", ) assert {f: f.read_text() for f in test_files} == { @@ -92,8 +97,9 @@ def test_run_in_wd_with_all_success(wd_tmp_path: Path) -> None: │ example2.py │ ✔ │ 0.00 % │ 25.00 % │ 2.00 % │ │ sub_example/__init__.py │ ✔ │ 100.00 % │ 50.00 % │ 100.00 % │ │ sub_example/example3.py │ ✔ │ 25.00 % │ 64.00 % │ 0.00 % │ +│ sub_example/example4.py │ ✔ │ 25.00 % │ 64.00 % │ 0.00 % │ ├─────────────────────────┼──────────┼───────────────┼─────────────────┼────────────────┤ -│ Total │ 100.00 % │ 42.50 % │ 50.00 % │ 21.00 % │ +│ Total │ 100.00 % │ 36.67 % │ 54.12 % │ 16.87 % │ └─────────────────────────┴──────────┴───────────────┴─────────────────┴────────────────┘ """.splitlines(), # noqa: E501 ) @@ -104,6 +110,7 @@ def test_run_in_wd_with_all_success(wd_tmp_path: Path) -> None: test_dir / "__init__.py", test_dir / "sub_example" / "__init__.py", test_dir / "sub_example" / "test_example3.py", + test_dir / "sub_example" / "test_example4.py", test_dir / "test_example1.py", test_dir / "test_example2.py", test_dir / "test_sub_example.py", @@ -116,6 +123,7 @@ def test_run_in_wd_with_all_success(wd_tmp_path: Path) -> None: wd_tmp_path / "targets" / "example2.py", wd_tmp_path / "targets" / "sub_example" / "__init__.py", wd_tmp_path / "targets" / "sub_example" / "example3.py", + wd_tmp_path / "targets" / "sub_example" / "example4.py", ) assert tuple(csv_file.read_text().splitlines()) == ( ( @@ -129,10 +137,12 @@ def test_run_in_wd_with_all_success(wd_tmp_path: Path) -> None: "example2.py,1.0,1,1,0.0,3,0,0.25,8,2,0.02,50,1", "sub_example/__init__.py,1.0,1,1,1.0,7,7,0.5,12,6,1.0,1,1", "sub_example/example3.py,1.0,1,1,0.25,20,5,0.64,25,16,0.0,49,0", - "total,1.0,4,4,0.425,40,17,0.5,60,30,0.21,200,42", + "sub_example/example4.py,1.0,1,1,0.25,20,5,0.64,25,16,0.0,49,0", + "total,1.0,5,5,0.36666666666666664,60,22,0.5411764705882353,85,46,0.1686746987951807,249,42", ) targets = ( targets_dir / "sub_example" / "example3.py", + targets_dir / "sub_example" / "example4.py", targets_dir / "example1.py", targets_dir / "example2.py", targets_dir / "sub_example" / "__init__.py", @@ -156,8 +166,9 @@ def test_run_in_wd_with_all_failures(wd_tmp_path: Path) -> None: │ example2.py │ ✖ │ 0.00 % │ 25.00 % │ 2.00 % │ │ sub_example/__init__.py │ ✖ │ 100.00 % │ 50.00 % │ 100.00 % │ │ sub_example/example3.py │ ✖ │ 25.00 % │ 64.00 % │ 0.00 % │ +│ sub_example/example4.py │ ✖ │ 25.00 % │ 64.00 % │ 0.00 % │ ├─────────────────────────┼─────────┼───────────────┼─────────────────┼────────────────┤ -│ Total │ 0.00 % │ 42.50 % │ 50.00 % │ 21.00 % │ +│ Total │ 0.00 % │ 36.67 % │ 54.12 % │ 16.87 % │ └─────────────────────────┴─────────┴───────────────┴─────────────────┴────────────────┘ Add -v to show the failed generation results. """.splitlines(), @@ -171,6 +182,7 @@ def test_run_in_wd_with_all_failures(wd_tmp_path: Path) -> None: wd_tmp_path / "targets" / "example2.py", wd_tmp_path / "targets" / "sub_example" / "__init__.py", wd_tmp_path / "targets" / "sub_example" / "example3.py", + wd_tmp_path / "targets" / "sub_example" / "example4.py", ) assert tuple(csv_file.read_text().splitlines()) == ( ( @@ -184,7 +196,8 @@ def test_run_in_wd_with_all_failures(wd_tmp_path: Path) -> None: "example2.py,0.0,1,0,0.0,3,0,0.25,8,2,0.02,50,1", "sub_example/__init__.py,0.0,1,0,1.0,7,7,0.5,12,6,1.0,1,1", "sub_example/example3.py,0.0,1,0,0.25,20,5,0.64,25,16,0.0,49,0", - "total,0.0,4,0,0.425,40,17,0.5,60,30,0.21,200,42", + "sub_example/example4.py,0.0,1,0,0.25,20,5,0.64,25,16,0.0,49,0", + "total,0.0,5,0,0.36666666666666664,60,22,0.5411764705882353,85,46,0.1686746987951807,249,42", ) @@ -201,8 +214,9 @@ def test_run_in_wd_with_all_exceptions(wd_tmp_path: Path) -> None: │ example2.py │ ✖ │ 0.00 % │ 25.00 % │ 2.00 % │ │ sub_example/__init__.py │ ✖ │ 100.00 % │ 50.00 % │ 100.00 % │ │ sub_example/example3.py │ ✖ │ 25.00 % │ 64.00 % │ 0.00 % │ +│ sub_example/example4.py │ ✖ │ 25.00 % │ 64.00 % │ 0.00 % │ ├─────────────────────────┼─────────┼───────────────┼─────────────────┼────────────────┤ -│ Total │ 0.00 % │ 42.50 % │ 50.00 % │ 21.00 % │ +│ Total │ 0.00 % │ 36.67 % │ 54.12 % │ 16.87 % │ └─────────────────────────┴─────────┴───────────────┴─────────────────┴────────────────┘ Add -v to show the failed generation results. """.splitlines(), @@ -216,6 +230,7 @@ def test_run_in_wd_with_all_exceptions(wd_tmp_path: Path) -> None: wd_tmp_path / "targets" / "example2.py", wd_tmp_path / "targets" / "sub_example" / "__init__.py", wd_tmp_path / "targets" / "sub_example" / "example3.py", + wd_tmp_path / "targets" / "sub_example" / "example4.py", ) assert tuple(csv_file.read_text().splitlines()) == ( ( @@ -229,7 +244,8 @@ def test_run_in_wd_with_all_exceptions(wd_tmp_path: Path) -> None: "example2.py,0.0,1,0,0.0,3,0,0.25,8,2,0.02,50,1", "sub_example/__init__.py,0.0,1,0,1.0,7,7,0.5,12,6,1.0,1,1", "sub_example/example3.py,0.0,1,0,0.25,20,5,0.64,25,16,0.0,49,0", - "total,0.0,4,0,0.425,40,17,0.5,60,30,0.21,200,42", + "sub_example/example4.py,0.0,1,0,0.25,20,5,0.64,25,16,0.0,49,0", + "total,0.0,5,0,0.36666666666666664,60,22,0.5411764705882353,85,46,0.1686746987951807,249,42", ) @@ -247,6 +263,7 @@ def test_run_in_wd_with_abort(wd_tmp_path: Path) -> None: wd_tmp_path / "targets" / "example2.py", wd_tmp_path / "targets" / "sub_example" / "__init__.py", wd_tmp_path / "targets" / "sub_example" / "example3.py", + wd_tmp_path / "targets" / "sub_example" / "example4.py", ) @@ -263,8 +280,9 @@ def test_run_with_different_targets(wd_tmp_path: Path) -> None: │ example2.py │ ✖ │ 0.00 % │ 25.00 % │ 2.00 % │ │ sub_example/__init__.py │ ✔ │ 100.00 % │ 50.00 % │ 100.00 % │ │ sub_example/example3.py │ ✔ │ 25.00 % │ 64.00 % │ 0.00 % │ +│ sub_example/example4.py │ ✔ │ 25.00 % │ 64.00 % │ 0.00 % │ ├─────────────────────────┼─────────┼───────────────┼─────────────────┼────────────────┤ -│ Total │ 50.00 % │ 42.50 % │ 50.00 % │ 21.00 % │ +│ Total │ 60.00 % │ 36.67 % │ 54.12 % │ 16.87 % │ └─────────────────────────┴─────────┴───────────────┴─────────────────┴────────────────┘ Add -v to show the failed generation results. """.splitlines(), @@ -276,6 +294,7 @@ def test_run_with_different_targets(wd_tmp_path: Path) -> None: test_dir / "__init__.py", test_dir / "sub_example" / "__init__.py", test_dir / "sub_example" / "test_example3.py", + test_dir / "sub_example" / "test_example4.py", test_dir / "test_sub_example.py", ) csv_file = results_dir / "statistics.csv" @@ -292,10 +311,12 @@ def test_run_with_different_targets(wd_tmp_path: Path) -> None: "example2.py,0.0,1,0,0.0,3,0,0.25,8,2,0.02,50,1", "sub_example/__init__.py,1.0,1,1,1.0,7,7,0.5,12,6,1.0,1,1", "sub_example/example3.py,1.0,1,1,0.25,20,5,0.64,25,16,0.0,49,0", - "total,0.5,4,2,0.425,40,17,0.5,60,30,0.21,200,42", + "sub_example/example4.py,1.0,1,1,0.25,20,5,0.64,25,16,0.0,49,0", + "total,0.6,5,3,0.36666666666666664,60,22,0.5411764705882353,85,46,0.1686746987951807,249,42", ) targets = ( TARGETS_DIR / "sub_example" / "example3.py", + TARGETS_DIR / "sub_example" / "example4.py", TARGETS_DIR / "sub_example" / "__init__.py", ) assert {f: f.read_text() for f in test_files} == { @@ -315,8 +336,9 @@ def test_run_with_real_tests(wd_tmp_path: Path) -> None: │ example2.py │ ✖ │ 0.00 % │ 100.00 % │ 0.00 % │ │ sub_example/__init__.py │ ✖ │ 0.00 % │ 0.00 % │ 0.00 % │ │ sub_example/example3.py │ ✔ │ 100.00 % │ 100.00 % │ 100.00 % │ +│ sub_example/example4.py │ ✖ │ 0.00 % │ 100.00 % │ 100.00 % │ ├─────────────────────────┼─────────┼───────────────┼─────────────────┼────────────────┤ -│ Total │ 50.00 % │ 36.84 % │ 16.67 % │ 33.33 % │ +│ Total │ 40.00 % │ 29.17 % │ 16.67 % │ 33.33 % │ └─────────────────────────┴─────────┴───────────────┴─────────────────┴────────────────┘ Add -v to show the failed generation results. """.splitlines(), @@ -351,7 +373,8 @@ def test_run_with_real_tests(wd_tmp_path: Path) -> None: "example2.py,0.0,1,0,0.0,2,0,1.0,0,0,0.0,13,0", "sub_example/__init__.py,0.0,1,0,0.0,5,0,0.0,2,0,0.0,23,0", "sub_example/example3.py,1.0,1,1,1.0,3,3,1.0,0,0,1.0,11,11", - "total,0.5,4,2,0.3684210526315789,19,7,0.16666666666666666,6,1,0.3333333333333333,84,28", + "sub_example/example4.py,0.0,1,0,0.0,5,0,1.0,0,0,1.0,0,0", + "total,0.4,5,2,0.2916666666666667,24,7,0.16666666666666666,6,1,0.3333333333333333,84,28", ) targets = (TARGETS_DIR / "sub_example" / "example3.py", TARGETS_DIR / "example1.py") assert {f: f.read_text() for f in test_files} == { @@ -375,8 +398,9 @@ def test_run_with_different_targets_and_dummy(wd_tmp_path: Path) -> None: │ example2.py │ ✔ │ 0.00 % │ 25.00 % │ 2.00 % │ │ sub_example/__init__.py │ ✔ │ 100.00 % │ 50.00 % │ 100.00 % │ │ sub_example/example3.py │ ✔ │ 25.00 % │ 64.00 % │ 0.00 % │ +│ sub_example/example4.py │ ✔ │ 25.00 % │ 64.00 % │ 0.00 % │ ├─────────────────────────┼──────────┼───────────────┼─────────────────┼────────────────┤ -│ Total │ 100.00 % │ 42.50 % │ 50.00 % │ 21.00 % │ +│ Total │ 100.00 % │ 36.67 % │ 54.12 % │ 16.87 % │ └─────────────────────────┴──────────┴───────────────┴─────────────────┴────────────────┘ """.splitlines(), # noqa: E501 ) @@ -387,6 +411,7 @@ def test_run_with_different_targets_and_dummy(wd_tmp_path: Path) -> None: test_dir / "__init__.py", test_dir / "sub_example" / "__init__.py", test_dir / "sub_example" / "test_example3.py", + test_dir / "sub_example" / "test_example4.py", test_dir / "test_example1.py", test_dir / "test_example2.py", test_dir / "test_sub_example.py", @@ -405,10 +430,12 @@ def test_run_with_different_targets_and_dummy(wd_tmp_path: Path) -> None: "example2.py,1.0,1,1,0.0,3,0,0.25,8,2,0.02,50,1", "sub_example/__init__.py,1.0,1,1,1.0,7,7,0.5,12,6,1.0,1,1", "sub_example/example3.py,1.0,1,1,0.25,20,5,0.64,25,16,0.0,49,0", - "total,1.0,4,4,0.425,40,17,0.5,60,30,0.21,200,42", + "sub_example/example4.py,1.0,1,1,0.25,20,5,0.64,25,16,0.0,49,0", + "total,1.0,5,5,0.36666666666666664,60,22,0.5411764705882353,85,46,0.1686746987951807,249,42", ) targets = ( TARGETS_DIR / "sub_example" / "example3.py", + TARGETS_DIR / "sub_example" / "example4.py", TARGETS_DIR / "example1.py", TARGETS_DIR / "example2.py", TARGETS_DIR / "sub_example" / "__init__.py", @@ -445,8 +472,9 @@ def test_run_with_different_targets_and_results(wd_tmp_path: Path) -> None: │ example2.py │ ✖ │ 0.00 % │ 25.00 % │ 2.00 % │ │ sub_example/__init__.py │ ✔ │ 100.00 % │ 50.00 % │ 100.00 % │ │ sub_example/example3.py │ ✔ │ 25.00 % │ 64.00 % │ 0.00 % │ +│ sub_example/example4.py │ ✔ │ 25.00 % │ 64.00 % │ 0.00 % │ ├─────────────────────────┼─────────┼───────────────┼─────────────────┼────────────────┤ -│ Total │ 50.00 % │ 42.50 % │ 50.00 % │ 21.00 % │ +│ Total │ 60.00 % │ 36.67 % │ 54.12 % │ 16.87 % │ └─────────────────────────┴─────────┴───────────────┴─────────────────┴────────────────┘ Add -v to show the failed generation results. """.splitlines(), @@ -457,6 +485,7 @@ def test_run_with_different_targets_and_results(wd_tmp_path: Path) -> None: test_dir / "__init__.py", test_dir / "sub_example" / "__init__.py", test_dir / "sub_example" / "test_example3.py", + test_dir / "sub_example" / "test_example4.py", test_dir / "test_sub_example.py", ) csv_file = results_dir / "statistics.csv" @@ -473,10 +502,12 @@ def test_run_with_different_targets_and_results(wd_tmp_path: Path) -> None: "example2.py,0.0,1,0,0.0,3,0,0.25,8,2,0.02,50,1", "sub_example/__init__.py,1.0,1,1,1.0,7,7,0.5,12,6,1.0,1,1", "sub_example/example3.py,1.0,1,1,0.25,20,5,0.64,25,16,0.0,49,0", - "total,0.5,4,2,0.425,40,17,0.5,60,30,0.21,200,42", + "sub_example/example4.py,1.0,1,1,0.25,20,5,0.64,25,16,0.0,49,0", + "total,0.6,5,3,0.36666666666666664,60,22,0.5411764705882353,85,46,0.1686746987951807,249,42", ) targets = ( TARGETS_DIR / "sub_example" / "example3.py", + TARGETS_DIR / "sub_example" / "example4.py", TARGETS_DIR / "sub_example" / "__init__.py", ) assert {f: f.read_text() for f in test_files} == { @@ -629,6 +660,8 @@ def _cosmic_ray_files(results_dir: Path) -> tuple[Path, ...]: results_dir / "cosmic_ray" / "example2.toml", results_dir / "cosmic_ray" / "sub_example.example3.sqlite", results_dir / "cosmic_ray" / "sub_example.example3.toml", + results_dir / "cosmic_ray" / "sub_example.example4.sqlite", + results_dir / "cosmic_ray" / "sub_example.example4.toml", results_dir / "cosmic_ray" / "sub_example.sqlite", results_dir / "cosmic_ray" / "sub_example.toml", ) @@ -639,6 +672,7 @@ def _coverages_files(results_dir: Path) -> tuple[Path, ...]: results_dir / "coverages" / "example1.xml", results_dir / "coverages" / "example2.xml", results_dir / "coverages" / "sub_example.example3.xml", + results_dir / "coverages" / "sub_example.example4.xml", results_dir / "coverages" / "sub_example.xml", ) diff --git a/tests/test_generators.py b/tests/test_generators.py index e4673bb..566e13d 100644 --- a/tests/test_generators.py +++ b/tests/test_generators.py @@ -36,6 +36,9 @@ def test_import_module() -> None: / "sub_example" / "__init__.py": frozenset({"annotations", "helper"}), TARGETS_DIR / "sub_example" / "example3.py": frozenset({"example"}), + TARGETS_DIR + / "sub_example" + / "example4.py": frozenset({"compress_string", "decompress_string", "gzip"}), } diff --git a/tests/test_target_finder.py b/tests/test_target_finder.py index 2df3993..a8f3320 100644 --- a/tests/test_target_finder.py +++ b/tests/test_target_finder.py @@ -54,4 +54,11 @@ def test_find_targets(generator_name: GeneratorName) -> None: test=tests / "sub_example" / "test_example3.py", test_module="generated_tests.sub_example.test_example3", ), + Target( + source=TARGETS_DIR / "sub_example" / "example4.py", + relative_source=Path("sub_example", "example4.py"), + source_module="sub_example.example4", + test=tests / "sub_example" / "test_example4.py", + test_module="generated_tests.sub_example.test_example4", + ), )