Commit 60dd592
refactor: bind embargo.api.check_course_access at call time
Running `pytest openedx/core/djangoapps/embargo/tests/` in isolation
fails one test because `test_redirect_if_blocked_courseware` mocks
`embargo.api.check_course_access`, and the mocked call triggers the
first-time import of `embargo.views`. views.py's `from .api import
check_course_access` captures the MagicMock as
`views.check_course_access` permanently. CI doesn't hit this because
earlier shard directories preload `embargo.views` before any mock
fires. Reproduces on master.
Calling via the module attribute resolves at call time, so future
mocks on the api function stay visible to the view.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent 00f7d86 commit 60dd592
1 file changed
Lines changed: 2 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
| 16 | + | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
| |||
48 | 47 | | |
49 | 48 | | |
50 | 49 | | |
51 | | - | |
| 50 | + | |
52 | 51 | | |
53 | 52 | | |
54 | 53 | | |
| |||
0 commit comments