Skip to content

Commit 1e093d0

Browse files
authoredMar 19, 2025
Update watch_test.py
Changes made to check whether entire log is printed or not.
1 parent 1268769 commit 1e093d0

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed
 

‎kubernetes/base/watch/watch_test.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,9 @@ def test_pod_log_empty_lines(self):
540540
#Mock logs used for this test
541541
w.stream = Mock(return_value=[
542542
"Hello from Docker",
543-
"\n", # Empty line
543+
"", # Empty line
544544
"Another log line",
545-
"\n", # Another empty line
545+
"", # Another empty line
546546
"Final log"
547547
])
548548
for event in w.stream(self.api.read_namespaced_pod_log, name=pod_name, namespace=self.namespace, follow=True):
@@ -552,7 +552,16 @@ def test_pod_log_empty_lines(self):
552552
# Print outputs
553553
print(f"Captured logs: {log_output}")
554554
# self.assertTrue(any("Hello from Docker" in line for line in log_output))
555-
self.assertTrue(any(line.strip() == "" for line in log_output), "No empty lines found in logs")
555+
# self.assertTrue(any(line.strip() == "" for line in log_output), "No empty lines found in logs")
556+
expected_log = [
557+
"Hello from Docker",
558+
"",
559+
"Another log line",
560+
"",
561+
"Final log"
562+
]
563+
564+
self.assertEqual(log_output, expected_log, "Captured logs do not match expected logs")
556565

557566
except ApiException as e:
558567
self.fail(f"Kubernetes API exception: {e}")

0 commit comments

Comments
 (0)
Failed to load comments.