File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -124,7 +124,6 @@ def _run(self) -> None:
124124 # Receive multipart message [topic, payload]
125125 msg_parts = self .socket .recv_multipart ()
126126 if len (msg_parts ) == 2 :
127- received_topic = msg_parts [0 ].decode ('utf-8' )
128127 payload = msgpack .unpackb (msg_parts [1 ], raw = False )
129128
130129 # Process and write the event to file
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ def setUp(self):
2222 # Use a unique port for each test to avoid conflicts
2323 self .endpoint = "tcp://127.0.0.1:5555"
2424 self .topic = "test_topic"
25- self .consumer_output = tempfile .mktemp (suffix = ".log" )
25+ self .consumer_output = tempfile .NamedTemporaryFile (suffix = ".log" , delete = False ). name
2626
2727 # Clean up any existing output file
2828 if os .path .exists (self .consumer_output ):
@@ -126,7 +126,7 @@ def test_zmq_topic_filtering(self):
126126 Note: This test may fail occasionally due to ZeroMQ's asynchronous nature and SUB socket's "slow joiner" problem.
127127 """
128128 # Simplified test: create one consumer with a specific topic and send matching messages
129- consumer_output = tempfile .mktemp (suffix = ".log" )
129+ consumer_output = tempfile .NamedTemporaryFile (suffix = ".log" , delete = False ). name
130130
131131 # Create consumer with topic "test_topic"
132132 consumer = ZeroMQFileConsumer (
Original file line number Diff line number Diff line change @@ -70,7 +70,8 @@ def test_zmq_integration():
7070 with open (output , 'r' ) as f :
7171 content = f .read ()
7272
73- print (f"Output file contains { content .count ('\n ' )} lines" )
73+ newline = '\n '
74+ print (f"Output file contains { content .count (newline )} lines" )
7475 print ("First 3 lines:" )
7576 for line in content .split ('\n ' )[:3 ]:
7677 if line :
@@ -81,20 +82,20 @@ def test_zmq_integration():
8182 print (f"Found { test_messages_found } /5 test messages in the output file" )
8283 if test_messages_found > 0 :
8384 print ("Test PASSED: ZeroMQ integration works correctly!" )
84- return True
85+ assert True # For pytest
8586 else :
8687 print ("Test FAILED: No test messages found in the output file" )
87- return False
88+ assert False # For pytest
8889 else :
8990 print (f"Test FAILED: Output file { output } was not created" )
90- return False
91+ assert False # For pytest
9192
9293 except Exception as e :
9394 print (f"Test FAILED with exception: { e } " )
9495 import traceback
9596
9697 traceback .print_exc ()
97- return False
98+ assert False # For pytest
9899
99100 finally :
100101 # Clean up
You can’t perform that action at this time.
0 commit comments