From 6a31a0452c2aeacc688a7835703c7e9386c45a6f Mon Sep 17 00:00:00 2001 From: Andrew Erickson Date: Mon, 29 Jul 2024 18:57:20 -0700 Subject: [PATCH 1/2] fix output logic, update test --- tf_authoritative_scanner/scanner.py | 11 +++++------ tf_authoritative_scanner/scanner_test.py | 4 +++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tf_authoritative_scanner/scanner.py b/tf_authoritative_scanner/scanner.py index 5dc5c0d..027bfda 100755 --- a/tf_authoritative_scanner/scanner.py +++ b/tf_authoritative_scanner/scanner.py @@ -111,12 +111,11 @@ def run(self, paths): if file_entry["authoritative"]: authoritative_files_found += 1 - if self.verbosity: - authoritative_lines = file_entry["authoritative_lines"] - for item in authoritative_lines: - line_number = item["line_number"] - line = item["line"] - print(f"AUTHORITATIVE: {file_path}:{line_number}: {line}") + authoritative_lines = file_entry["authoritative_lines"] + for item in authoritative_lines: + line_number = item["line_number"] + line = item["line"] + print(f"AUTHORITATIVE: {file_path}:{line_number}: {line}") elif file_entry["excepted_lines"]: if self.verbosity: excepted_lines = file_entry["excepted_lines"] diff --git a/tf_authoritative_scanner/scanner_test.py b/tf_authoritative_scanner/scanner_test.py index 575b326..0b75054 100644 --- a/tf_authoritative_scanner/scanner_test.py +++ b/tf_authoritative_scanner/scanner_test.py @@ -184,7 +184,9 @@ def test_main_function_invalid(self): def test_main_directory_fail(self, temp_tf_dir): result = subprocess.run(["tfas", temp_tf_dir], capture_output=True, text=True) assert result.stderr == "" - assert result.stdout == "FAIL: 1 of 1 scanned files are authoritative.\n" + assert "FAIL: 1 of 1 scanned files are authoritative.\n" in result.stdout + # ensure that authoritative messages are emitted in non-verbose mode + assert "AUTHORITATIVE" in result.stdout assert result.returncode == 1 def test_main_directory_ok(self, temp_non_authoritative_tf_file): From da5a2d82844b02226389c58c40a20a0753d49f44 Mon Sep 17 00:00:00 2001 From: Andrew Erickson Date: Mon, 29 Jul 2024 18:57:56 -0700 Subject: [PATCH 2/2] version rev --- tf_authoritative_scanner/scanner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tf_authoritative_scanner/scanner.py b/tf_authoritative_scanner/scanner.py index 027bfda..3f268cb 100755 --- a/tf_authoritative_scanner/scanner.py +++ b/tf_authoritative_scanner/scanner.py @@ -5,7 +5,7 @@ import sys import argparse -VERSION = "1.0.2" +VERSION = "1.0.3" class TFAuthoritativeScanner: