]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
More tolerance in schedule timing tests
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 8 Mar 2021 01:41:53 +0000 (02:41 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 12 Mar 2021 04:07:25 +0000 (05:07 +0100)
tests/pool/test_sched.py

index 3ca6cb1f08a779df62ac9d3a5d2663b0dd6fced5..fdd9222653d5ec00b25c3bd93b70fddc09b7793d 100644 (file)
@@ -24,9 +24,9 @@ def test_sched():
     s.run()
     assert len(results) == 2
     assert results[0][0] == 1
-    assert results[0][1] - t0 == pytest.approx(0.1, 0.01)
+    assert results[0][1] - t0 == pytest.approx(0.1, 0.1)
     assert results[1][0] == 2
-    assert results[1][1] - t0 == pytest.approx(0.2, 0.01)
+    assert results[1][1] - t0 == pytest.approx(0.2, 0.1)
 
 
 @pytest.mark.slow
@@ -48,13 +48,13 @@ def test_sched_thread():
 
     t.join()
     t1 = time()
-    assert t1 - t0 == pytest.approx(0.3, 0.01)
+    assert t1 - t0 == pytest.approx(0.3, 0.1)
 
     assert len(results) == 2
     assert results[0][0] == 1
-    assert results[0][1] - t0 == pytest.approx(0.1, 0.01)
+    assert results[0][1] - t0 == pytest.approx(0.1, 0.1)
     assert results[1][0] == 2
-    assert results[1][1] - t0 == pytest.approx(0.2, 0.01)
+    assert results[1][1] - t0 == pytest.approx(0.2, 0.1)
 
 
 @pytest.mark.slow
@@ -80,13 +80,13 @@ def test_sched_error(caplog):
 
     t.join()
     t1 = time()
-    assert t1 - t0 == pytest.approx(0.4, 0.01)
+    assert t1 - t0 == pytest.approx(0.4, 0.1)
 
     assert len(results) == 2
     assert results[0][0] == 1
-    assert results[0][1] - t0 == pytest.approx(0.1, 0.01)
+    assert results[0][1] - t0 == pytest.approx(0.1, 0.1)
     assert results[1][0] == 2
-    assert results[1][1] - t0 == pytest.approx(0.3, 0.01)
+    assert results[1][1] - t0 == pytest.approx(0.3, 0.1)
 
     assert len(caplog.records) == 1
     assert "ZeroDivisionError" in caplog.records[0].message
@@ -116,7 +116,7 @@ def test_empty_queue_timeout():
     t.join()
     times.append(time() - t0)
     for got, want in zip(times, [0.2, 0.4, 0.5, 1.0]):
-        assert got == pytest.approx(want, 0.01)
+        assert got == pytest.approx(want, 0.1)
 
 
 @pytest.mark.slow
@@ -145,4 +145,4 @@ def test_first_task_rescheduling():
     t.join()
     times.append(time() - t0)
     for got, want in zip(times, [0.1, 0.2, 0.4, 0.6, 0.6]):
-        assert got == pytest.approx(want, 0.01)
+        assert got == pytest.approx(want, 0.1)