Skip to content

Conversation

@bernhardkaindl
Copy link
Contributor

@bernhardkaindl bernhardkaindl commented Sep 23, 2025

tests/unit/test_main.py: Restore DB_CONF (xapi db config) after test case execution

Fix the fixture which provides a patched bugtool for normal execution as an unprivileged user for tests:

  • To avoid leaking the patched DB_CONF string to other test cases, restore it after the test case.

Summary:

  • Converts the patched_bugtool into a yielding generator fixture.
    It:
    1. Saves the original DB_CONF,
    2. Patches the loaded bugtool module
    3. Yields the test parameters to the test execution, and
    4. After the test is done, it restores the DB_CONF string to its original value.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a test isolation issue in the patched_bugtool fixture by ensuring the DB_CONF attribute is properly restored after each test case execution.

  • Converts the fixture from a simple return to a generator with yield to enable proper cleanup
  • Saves and restores the original DB_CONF value to prevent test interference
  • Adds documentation clarifying the function-scoped nature of the fixture

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@bernhardkaindl bernhardkaindl force-pushed the fix-patched_bugtool-fixture-to-save-restore-db.conf branch from 16198f4 to bf53de8 Compare September 23, 2025 21:16
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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.

1 participant