Skip to content

Commit

Permalink
sdk: make test_batch_span_processor_scheduled_delay a bit more robust
Browse files Browse the repository at this point in the history
It happened that tests failed because the delay was fired some
microseconds earlier:

>       self.assertGreaterEqual((export_time - start_time) * 1e3, 500)
E       AssertionError: 499.9737739562988 not greater than or equal to 500

Use assertAlmostEqual to accept a similar enough value (delta=1) and
avoid too big values.

Fix open-telemetry#3911
  • Loading branch information
xrmx committed Jun 13, 2024
1 parent ba22b16 commit ce74344
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion opentelemetry-sdk/tests/trace/export/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def test_batch_span_processor_scheduled_delay(self):
self.assertTrue(export_event.wait(2))
export_time = time.time()
self.assertEqual(len(spans_names_list), 1)
self.assertGreaterEqual((export_time - start_time) * 1e3, 500)
self.assertAlmostEqual((export_time - start_time) * 1e3, 500, delta=1)

span_processor.shutdown()

Expand Down

0 comments on commit ce74344

Please sign in to comment.