Skip to content

Commit 99c2c96

Browse files
committed
test_cmdline: Remove unnecessary asserts for log messages
It is becoming difficult to make changes to our code because our command-line tests are getting very picky. In particular we have too many tests that - in addition to verifying some specific, intended behavior - also check for specific log messages in their output. When we refactor and change code internally, we often have to fix these tests as well, even though the tests themselves are not closely related to the code we're changing. Make the situation a little easier by removing the verification of INFO-level log messages from some of our CLI tests. There are still several INFO-level log message verification remaining, as we do want _some_ test coverage of these messages.
1 parent b0e168b commit 99c2c96

File tree

1 file changed

+6
-50
lines changed

1 file changed

+6
-50
lines changed

tests/test_cmdline.py

+6-50
Original file line numberDiff line numberDiff line change
@@ -436,17 +436,10 @@ def test_check__simple_project_with_missing_deps__reports_undeclared(
436436
"- 'requests' imported at:",
437437
f" {str(tmp_path / 'code.py')}:1",
438438
]
439-
expect_logs = [
440-
f"INFO:fawltydeps.extract_imports:Finding Python files under {tmp_path}",
441-
f"INFO:fawltydeps.extract_imports:Parsing Python file {tmp_path}/code.py",
442-
"INFO:fawltydeps.packages:'pandas' was not resolved."
443-
" Assuming it can be imported as 'pandas'.",
444-
]
445-
output, errors, returncode = run_fawltydeps(
439+
output, _errors, returncode = run_fawltydeps(
446440
"--check", "--detailed", "-v", f"--code={tmp_path}", f"--deps={tmp_path}"
447441
)
448442
assert output.splitlines() == expect
449-
assert_unordered_equivalence(errors.splitlines(), expect_logs)
450443
assert returncode == 3
451444

452445

@@ -463,19 +456,10 @@ def test_check__simple_project_with_extra_deps__reports_unused(
463456
"- 'pandas' declared in:",
464457
f" {tmp_path / 'requirements.txt'}",
465458
]
466-
expect_logs = [
467-
f"INFO:fawltydeps.extract_imports:Finding Python files under {tmp_path}",
468-
f"INFO:fawltydeps.extract_imports:Parsing Python file {tmp_path}/code.py",
469-
"INFO:fawltydeps.packages:'requests' was not resolved."
470-
" Assuming it can be imported as 'requests'.",
471-
"INFO:fawltydeps.packages:'pandas' was not resolved."
472-
" Assuming it can be imported as 'pandas'.",
473-
]
474-
output, errors, returncode = run_fawltydeps(
459+
output, _errors, returncode = run_fawltydeps(
475460
"--check", "--detailed", "-v", f"--code={tmp_path}", f"--deps={tmp_path}"
476461
)
477462
assert output.splitlines() == expect
478-
assert_unordered_equivalence(errors.splitlines(), expect_logs)
479463
assert returncode == 4
480464

481465

@@ -496,17 +480,10 @@ def test_check__simple_project__can_report_both_undeclared_and_unused(
496480
"- 'pandas' declared in:",
497481
f" {tmp_path / 'requirements.txt'}",
498482
]
499-
expect_logs = [
500-
f"INFO:fawltydeps.extract_imports:Finding Python files under {tmp_path}",
501-
f"INFO:fawltydeps.extract_imports:Parsing Python file {tmp_path}/code.py",
502-
"INFO:fawltydeps.packages:'pandas' was not resolved."
503-
" Assuming it can be imported as 'pandas'.",
504-
]
505-
output, errors, returncode = run_fawltydeps(
483+
output, _errors, returncode = run_fawltydeps(
506484
"--check", "--detailed", "-v", f"--code={tmp_path}", f"--deps={tmp_path}"
507485
)
508486
assert output.splitlines() == expect
509-
assert_unordered_equivalence(errors.splitlines(), expect_logs)
510487
assert returncode == 3 # undeclared is more important than unused
511488

512489

@@ -527,13 +504,7 @@ def test_check__simple_project__summary_report_with_verbose_logging(
527504
"",
528505
VERBOSE_PROMPT,
529506
]
530-
expect_logs = [
531-
f"INFO:fawltydeps.extract_imports:Finding Python files under {tmp_path}",
532-
f"INFO:fawltydeps.extract_imports:Parsing Python file {tmp_path}/code.py",
533-
"INFO:fawltydeps.packages:'pandas' was not resolved."
534-
" Assuming it can be imported as 'pandas'.",
535-
]
536-
output, errors, returncode = run_fawltydeps(
507+
output, _errors, returncode = run_fawltydeps(
537508
"--check",
538509
"--summary",
539510
"--verbose",
@@ -542,7 +513,6 @@ def test_check__simple_project__summary_report_with_verbose_logging(
542513
f"{tmp_path}",
543514
)
544515
assert output.splitlines() == expect
545-
assert_unordered_equivalence(errors.splitlines(), expect_logs)
546516
assert returncode == 3 # undeclared is more important than unused
547517

548518

@@ -636,13 +606,7 @@ def test_check_undeclared__simple_project__reports_only_undeclared(
636606
"- 'requests' imported at:",
637607
f" {str(tmp_path / 'code.py')}:1",
638608
]
639-
expect_logs = [
640-
f"INFO:fawltydeps.extract_imports:Finding Python files under {tmp_path}",
641-
f"INFO:fawltydeps.extract_imports:Parsing Python file {tmp_path}/code.py",
642-
"INFO:fawltydeps.packages:'pandas' was not resolved."
643-
" Assuming it can be imported as 'pandas'.",
644-
]
645-
output, errors, returncode = run_fawltydeps(
609+
output, _errors, returncode = run_fawltydeps(
646610
"--check-undeclared",
647611
"--detailed",
648612
"-v",
@@ -651,7 +615,6 @@ def test_check_undeclared__simple_project__reports_only_undeclared(
651615
f"{tmp_path}",
652616
)
653617
assert output.splitlines() == expect
654-
assert_unordered_equivalence(errors.splitlines(), expect_logs)
655618
assert returncode == 3
656619

657620

@@ -668,13 +631,7 @@ def test_check_unused__simple_project__reports_only_unused(
668631
"- 'pandas' declared in:",
669632
f" {tmp_path / 'requirements.txt'}",
670633
]
671-
expect_logs = [
672-
f"INFO:fawltydeps.extract_imports:Finding Python files under {tmp_path}",
673-
f"INFO:fawltydeps.extract_imports:Parsing Python file {tmp_path}/code.py",
674-
"INFO:fawltydeps.packages:'pandas' was not resolved."
675-
" Assuming it can be imported as 'pandas'.",
676-
]
677-
output, errors, returncode = run_fawltydeps(
634+
output, _errors, returncode = run_fawltydeps(
678635
"--check-unused",
679636
"--detailed",
680637
"-v",
@@ -683,7 +640,6 @@ def test_check_unused__simple_project__reports_only_unused(
683640
f"{tmp_path}",
684641
)
685642
assert output.splitlines() == expect
686-
assert_unordered_equivalence(errors.splitlines(), expect_logs)
687643
assert returncode == 4
688644

689645

0 commit comments

Comments
 (0)