diff options
Diffstat (limited to 'bgproc_tests.py')
-rw-r--r-- | bgproc_tests.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/bgproc_tests.py b/bgproc_tests.py index 3f3634d..92e48cd 100644 --- a/bgproc_tests.py +++ b/bgproc_tests.py @@ -32,11 +32,21 @@ class BackgroundProcessingTests(unittest.TestCase): self.bg.close_requests() self.bg.finish() + def test_has_no_pending_initially(self): + self.assertEqual(self.bg.pending, 0) + def test_get_results_returns_nothing_initially(self): self.assertEqual(self.bg.get_results(), []) def test_processes_stuff(self): self.bg.enqueue_request(0) + + # The following is not a race condition, because the counter + # only gets decremented after get_results has retrieved the result, + # and we only call that later. + self.assertEqual(self.bg.pending, 1) + self.assertEqual(self.bg.get_results(block=True), [1]) + self.assertEqual(self.bg.pending, 0) self.assertEqual(self.bg.get_results(block=True), []) |