Skip to content

Commit

Permalink
Mock time.time for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eltoder committed Apr 11, 2024
1 parent b671f62 commit 2606d63
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions green/test/test_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ def test_startStop(self):
"""
ptr = ProtoTestResult()
test = proto_test(MagicMock())
ptr.startTest(test)
ptr.stopTest(test)
self.assertGreater(float(ptr.test_time), 0)
with patch("time.time", side_effect=[101, 123]):
ptr.startTest(test)
ptr.stopTest(test)
self.assertEqual(float(ptr.test_time), 22)

def test_addSuccess(self):
"""
Expand Down

0 comments on commit 2606d63

Please sign in to comment.