| Conditions | 2 |
| Total Lines | 22 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import pytest |
||
| 10 | @pytest.fixture |
||
| 11 | def broadcaster_class(): |
||
| 12 | class TestSubject: |
||
| 13 | def __init__(self, subject, done_callback): |
||
| 14 | self.subject = subject |
||
| 15 | self.done = done_callback |
||
| 16 | |||
| 17 | def iterate(self): |
||
| 18 | i = 0 |
||
| 19 | while not self.done(): |
||
| 20 | # do something in the current iteration |
||
| 21 | print('Iteration with index', i) |
||
| 22 | |||
| 23 | # notify when we have completed i+1 iterations |
||
| 24 | self.subject.state = type('Subject', (), { |
||
| 25 | 'metrics': {'iterations': i + 1}, # we have completed i+1 iterations |
||
| 26 | }) |
||
| 27 | self.subject.notify() |
||
| 28 | i += 1 |
||
| 29 | return i |
||
| 30 | |||
| 31 | return TestSubject |
||
| 32 | |||
| 54 |