diff options
Diffstat (limited to 't')
| -rw-r--r-- | t/eager_and_scheduled.py | 3 | ||||
| -rw-r--r-- | t/test_functionality.py | 18 | ||||
| -rw-r--r-- | t/utils.py | 7 |
3 files changed, 23 insertions, 5 deletions
diff --git a/t/eager_and_scheduled.py b/t/eager_and_scheduled.py index 178a9f4..030b539 100644 --- a/t/eager_and_scheduled.py +++ b/t/eager_and_scheduled.py @@ -8,7 +8,8 @@ async def foo(): async def bar(): - await asyncio.create_subprocess_shell('sleep 1.0') + proc = await asyncio.create_subprocess_shell('sleep 1.0') + await proc.communicate() async def baz(): diff --git a/t/test_functionality.py b/t/test_functionality.py index 5253534..12bf775 100644 --- a/t/test_functionality.py +++ b/t/test_functionality.py @@ -52,6 +52,22 @@ class BasicUsage(utils.AergiaUnitTestCase): samples = self.Aergia.get_samples() - print(self.expected_samples(delay * 3)) self.assertFuncContains('b', [self.expected_samples(delay * 3)], samples) + + # TODO samples from gather all execution time, should we trace this?? + self.assertFuncContains('a', [self.expected_samples(delay)], samples) + + def test_eager_task(self): + delay = 0.2 + + async def a(): + proc = await asyncio.create_subprocess_shell(f'sleep {delay}') + await proc.communicate() + + self.Aergia.start() + asyncio.run(a()) + self.Aergia.stop() + + samples = self.Aergia.get_samples() + self.assertFuncContains('a', [self.expected_samples(delay)], samples) @@ -13,16 +13,17 @@ class AergiaUnitTestCase(unittest.TestCase): def assertFuncContains(self, func_name, samples_expected, samples): samples_actual = self.extract_values_by_func(samples, func_name) - self.assertTrue(len(samples_expected) == len(samples_actual)) + self.assertTrue(len(samples_expected) == len(samples_actual), + f'{samples_expected} (expected) not length of ' + f'{samples_actual} (actual)') s1 = sorted(samples_expected) s2 = sorted(samples_actual) for v1, v2 in zip(s1, s2): self.assertRoughlyEqual(v1, v2) def assertRoughlyEqual(self, v1, v2): - print(f'{v1}, {v2}') a = abs(v1 - v2) - self.assertTrue(a <= 1) + self.assertTrue(a <= 1, f'{v1} (expected) not roughly {v2} (actual)') def expected_samples(self, total_seconds): return (total_seconds / self.interval) |
