Skip to content

Commit

Permalink
Fix flaky export.Printer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzalo-bulnes committed Dec 6, 2022
1 parent 10ce1af commit f6dfc90
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/export/test_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def test_printer_status_tracks_printing_service_responses_when_connected(self):
POLLING_INTERVAL = 200 # milliseconds
# There is a limit to the precision of the timer, but 50ms is plenty to play with.
FRACTION_OF_POLLING_INTERVAL = 50 # milliseconds
CHECK_EXECUTION_TIME = 20 # milliseconds

printer = getPrinter(printing_service, POLLING_INTERVAL)

Expand Down Expand Up @@ -216,7 +217,7 @@ def test_printer_status_tracks_printing_service_responses_when_connected(self):

# A new query is issued after the polling interval has elapsed,
# the dummy printing service response is almost instantaneous.
printing_service_response.wait(FRACTION_OF_POLLING_INTERVAL)
printing_service_response.wait(FRACTION_OF_POLLING_INTERVAL + CHECK_EXECUTION_TIME)
self.assertEqual(
2,
len(printing_service_response),
Expand All @@ -228,7 +229,7 @@ def test_printer_status_tracks_printing_service_responses_when_connected(self):
"Expected printer status to track the last response, did not.",
)

printing_service_response.wait(POLLING_INTERVAL)
printing_service_response.wait(POLLING_INTERVAL + CHECK_EXECUTION_TIME)
self.assertEqual(
3,
len(printing_service_response),
Expand All @@ -240,7 +241,7 @@ def test_printer_status_tracks_printing_service_responses_when_connected(self):
"Expected printer status to track the last response, did not.",
)

printing_service_response.wait(POLLING_INTERVAL)
printing_service_response.wait(POLLING_INTERVAL + CHECK_EXECUTION_TIME)
self.assertEqual(
4,
len(printing_service_response),
Expand All @@ -263,6 +264,7 @@ def test_printer_status_stops_tracking_printing_service_responses_when_disconnec
self.assertTrue(printing_service_response.isValid())

POLLING_INTERVAL = 100 # milliseconds
CHECK_EXECUTION_TIME = 20 # milliseconds
printer = getPrinter(printing_service, POLLING_INTERVAL)

self.ensure_that_printer_internals_are_ready_to_process_events(printer, 400)
Expand Down Expand Up @@ -304,7 +306,7 @@ def test_printer_status_stops_tracking_printing_service_responses_when_disconnec
"Expected printer status to become unknown as soon as disconnected.",
)

printing_service_response.wait(POLLING_INTERVAL) # will time out
printing_service_response.wait(POLLING_INTERVAL + CHECK_EXECUTION_TIME) # will time out
self.assertEqual(
1,
len(printing_service_response),
Expand Down

0 comments on commit f6dfc90

Please sign in to comment.