Skip to content

fix: restore all events in OpenEdxEventsTestMixin.tearDownClass#559

Merged
mariajgrimaldi merged 3 commits intomainfrom
feanil/fix-openedx-events-test-mixin-teardown
Apr 9, 2026
Merged

fix: restore all events in OpenEdxEventsTestMixin.tearDownClass#559
mariajgrimaldi merged 3 commits intomainfrom
feanil/fix-openedx-events-test-mixin-teardown

Conversation

@feanil
Copy link
Copy Markdown
Contributor

@feanil feanil commented Apr 6, 2026

Summary

OpenEdxEventsTestMixin.setUpClass() disables all OpenEdX events then enables only those in ENABLED_OPENEDX_EVENTS, but had no tearDownClass to restore event state. This meant that after any test class using this mixin completed, all events not in ENABLED_OPENEDX_EVENTS remained globally disabled for the remainder of the process.

This was discovered in openedx-platform when shard rebalancing caused lms/djangoapps/certificates/ and lms/djangoapps/discussion/django_comment_client/ to run in the same process for the first time. Nine certificate test classes with ENABLED_OPENEDX_EVENTS = [] left all events disabled, causing ForumEventTestCase.test_comment_event to fail with:

AttributeError: 'NoneType' object has no attribute 'kwargs'

because FORUM_RESPONSE_COMMENT_CREATED was never fired (it had been disabled).

Fix

  • Add tearDownClass to OpenEdxEventsTestMixin that calls enable_all_events(), mirroring the disable in
    setUpClass. This is consistent with the pattern already used by FreezeSignalCacheMixin in the same file.
  • This also fixes a bug introduced in Fix Read the Docs build, add "make serve_docs", fix many build warnings #557 which will break openedx-platform when it's released. See the refactor commit message for more details.

OpenEdxEventsTestMixin.setUpClass() disables all OpenEdX events then
enables only those listed in ENABLED_OPENEDX_EVENTS, but had no
corresponding tearDownClass to restore event state. This caused any
events left disabled to remain disabled for subsequent test classes
running in the same process.

Add tearDownClass to re-enable all events so that test classes using
this mixin do not leak disabled event state into other tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@feanil feanil marked this pull request as ready for review April 6, 2026 13:48
…ation

Verify that tearDownClass re-enables all events so subsequent test
classes running in the same process are not affected by the mixin's
event isolation — the regression that motivated the tearDownClass fix.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@feanil feanil force-pushed the feanil/fix-openedx-events-test-mixin-teardown branch from 238e42f to 0336d08 Compare April 6, 2026 14:04
feanil added a commit to openedx/openedx-platform that referenced this pull request Apr 8, 2026
…vents.testing

openedx_events/tests/utils.py was moved to openedx_events/testing.py in
openedx/openedx-events#559 so the test utilities are included in the
installed package (setup.py excludes the tests/ subpackage from the wheel).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
feanil added a commit to openedx/openedx-platform that referenced this pull request Apr 8, 2026
Pins openedx-events to the openedx/openedx-events#559 branch which
contains two fixes not yet in a released version:

- tearDownClass added to OpenEdxEventsTestMixin to restore event state
- Test utilities moved to openedx_events.testing so they are included
  in the installed package (setup.py excludes tests/ from the wheel)

Revert to unpinned once openedx/openedx-events#559 is merged and
released as 11.1.1.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
openedx_events/tests/utils.py was excluded from the installed package
by the exclude=["*tests"] in setup.py (introduced in #557), breaking
downstream consumers that import from openedx_events.tests.utils.

Move the public test utilities to openedx_events/testing.py so they
are included in the installed package. New import paths:

    from openedx_events.testing import FreezeSignalCacheMixin
    from openedx_events.testing import EventsIsolationMixin
    from openedx_events.testing import OpenEdxEventsTestMixin

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@feanil feanil force-pushed the feanil/fix-openedx-events-test-mixin-teardown branch from 3e475c1 to 171ce95 Compare April 8, 2026 19:09
Copy link
Copy Markdown
Member

@mariajgrimaldi mariajgrimaldi left a comment

Choose a reason for hiding this comment

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

Thanks a lot!

@mariajgrimaldi mariajgrimaldi merged commit a3f415b into main Apr 9, 2026
9 checks passed
@mariajgrimaldi mariajgrimaldi deleted the feanil/fix-openedx-events-test-mixin-teardown branch April 9, 2026 09:48
@mariajgrimaldi
Copy link
Copy Markdown
Member

feanil added a commit to openedx/openedx-platform that referenced this pull request Apr 9, 2026
…vents.testing

openedx_events/tests/utils.py was moved to openedx_events/testing.py in
openedx/openedx-events#559 so the test utilities are included in the
installed package (setup.py excludes the tests/ subpackage from the wheel).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
feanil added a commit to openedx/openedx-platform that referenced this pull request Apr 10, 2026
…vents.testing

openedx_events/tests/utils.py was moved to openedx_events/testing.py in
openedx/openedx-events#559 so the test utilities are included in the
installed package (setup.py excludes the tests/ subpackage from the wheel).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
feanil added a commit to openedx/openedx-platform that referenced this pull request Apr 10, 2026
…vents.testing

openedx_events/tests/utils.py was moved to openedx_events/testing.py in
openedx/openedx-events#559 so the test utilities are included in the
installed package (setup.py excludes the tests/ subpackage from the wheel).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
feanil added a commit to openedx/openedx-platform that referenced this pull request Apr 11, 2026
…vents.testing

openedx_events/tests/utils.py was moved to openedx_events/testing.py in
openedx/openedx-events#559 so the test utilities are included in the
installed package (setup.py excludes the tests/ subpackage from the wheel).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
feanil added a commit to openedx/openedx-platform that referenced this pull request Apr 14, 2026
…vents.testing

openedx_events/tests/utils.py was moved to openedx_events/testing.py in
openedx/openedx-events#559 so the test utilities are included in the
installed package (setup.py excludes the tests/ subpackage from the wheel).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

2 participants