Skip to content

Fixing Flakiness in api_test.py#169

Merged
sarayourfriend merged 1 commit intoh2non:masterfrom
pem70:Fix-flaky-api-test
Feb 28, 2026
Merged

Fixing Flakiness in api_test.py#169
sarayourfriend merged 1 commit intoh2non:masterfrom
pem70:Fix-flaky-api-test

Conversation

@pem70
Copy link
Copy Markdown
Contributor

@pem70 pem70 commented Dec 12, 2025

Description

Fixes #168.

This fix modifies the engine fixture in tests/api_test.py to use the pytest yield pattern. By moving the cleanup logic (api.off() and api.disable()) into the fixture's teardown phase, we guarantee that the global state is reset after every test, even if a test fails or crashes. This eliminates the "polluter" behavior where a single assertion failure causes cascading failures in subsequent tests.

It fixes the following tests: test_activate(), test_on(), test_use(), and test_mock_contructors().

PR Checklist

  • I've added tests for any code changes
  • I've documented any new features

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky tests in api_test.py due to shared global state

2 participants