-
Notifications
You must be signed in to change notification settings - Fork 43
Description
Description
The tests in tests/api_test.py have flakiness and lack proper isolation. They rely on shared global state pook.api engine and manual cleanup within the test bodies.
If a single test fails or crashes before it reaches its manual cleanup step, it pollutes the global environment. This causes all subsequent tests to fail because they expect a clean environment at the start of execution.
For example, in the following test:
def test_activate(engine):
assert engine.active is False
api.activate()
assert engine.active is True
api.disable()
assert engine.active is False
If assert engine.active is True fails, the tests will end before cleaning up. All the following tests would fail because engine was left active by the first failing test.
Expected Behavior
Tests should be atomic and isolated. A failure in test_activate() should result in exactly 1 failure. The remaining tests should pass, as their logic is correct.