Skip to content

Fix poor test isolation in plugs_test.py (issue #753)#1294

Open
harrish243 wants to merge 1 commit into
google:masterfrom
harrish243:fix/plugs-test-isolation-753
Open

Fix poor test isolation in plugs_test.py (issue #753)#1294
harrish243 wants to merge 1 commit into
google:masterfrom
harrish243:fix/plugs-test-isolation-753

Conversation

@harrish243

Copy link
Copy Markdown

Fixes #753

plugs_test.py had several class-level state leaks that made tests order-dependent and relied (in older versions) on a real socket being opened by FrontendAwareBasePlug via xmlrpcutil.SimpleThreadedXmlRpcServer.

Changes:

  • Add module-level docstring explaining the hermetic design contract.
  • Reset AdderPlug.LAST_INSTANCE in setUp() so each test starts with a clean slate (previously only INSTANCE_COUNT was reset, causing the LAST_INSTANCE reference from one test to bleed into the next).
  • Reset TearDownRaisesPlug1.TORN_DOWN and TearDownRaisesPlug2.TORN_DOWN in setUp() so test_tear_down_raises cannot influence other tests via shared class-level boolean state.
  • Add class-level and method-level docstrings that document why state is reset and confirm that no network socket is opened.
  • Add a docstring to test_plug_updates() making it explicit that the update-notification path uses only in-process threading.Event objects (via SubscribableStateMixin) and no socket is involved.

All 9 existing tests continue to pass.

@google-cla

google-cla Bot commented Jun 24, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

plugs_test.py had several class-level state leaks that made tests
order-dependent and relied (in older versions) on a real socket being
opened by FrontendAwareBasePlug via xmlrpcutil.SimpleThreadedXmlRpcServer.

Changes:
- Add module-level docstring explaining the hermetic design contract.
- Reset AdderPlug.LAST_INSTANCE in setUp() so each test starts with a
  clean slate (previously only INSTANCE_COUNT was reset, causing the
  LAST_INSTANCE reference from one test to bleed into the next).
- Reset TearDownRaisesPlug1.TORN_DOWN and TearDownRaisesPlug2.TORN_DOWN
  in setUp() so test_tear_down_raises cannot influence other tests via
  shared class-level boolean state.
- Add class-level and method-level docstrings that document why state
  is reset and confirm that no network socket is opened.
- Add a docstring to test_plug_updates() making it explicit that the
  update-notification path uses only in-process threading.Event objects
  (via SubscribableStateMixin) and no socket is involved.

All 9 existing tests continue to pass.
@harrish243 harrish243 force-pushed the fix/plugs-test-isolation-753 branch from 6907f56 to 22c1362 Compare June 24, 2026 04:17
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.

plugs_test.py poorly isolated (relies upon socket)

1 participant