From 36e458d95764b78d5559068a5f484cb7f1126f12 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Wed, 17 Sep 2025 11:25:20 -0400 Subject: [PATCH] fix: Use CI oriented FakeWebpackLoader This was added in a newer version of django-webpack loader to be used in CI. Previously we had some monkey patches to deal with this but they could break when changes happen to the upstream django-webpack-loader library. This should be a more robust solution to keep CI working and to reduce complexity on future upgrades. --- cms/conftest.py | 20 -------------------- cms/envs/test.py | 1 + conftest.py | 16 ---------------- lms/envs/test.py | 1 + 4 files changed, 2 insertions(+), 36 deletions(-) diff --git a/cms/conftest.py b/cms/conftest.py index 0fb285f8bd..131ea8e048 100644 --- a/cms/conftest.py +++ b/cms/conftest.py @@ -40,23 +40,3 @@ def _django_clear_site_cache(): with what has been working for us so far. """ pass # lint-amnesty, pylint: disable=unnecessary-pass - - -@pytest.fixture(autouse=True) -def no_webpack_loader(monkeypatch): - """ - Monkeypatch webpack_loader to make sure that webpack assets don't need to be - compiled before unit tests are run. - """ - monkeypatch.setattr( - "webpack_loader.templatetags.webpack_loader.render_bundle", - lambda context, entry, extension=None, config='DEFAULT', attrs='': '' - ) - monkeypatch.setattr( - "webpack_loader.utils.get_as_tags", - lambda entry, extension=None, config='DEFAULT', attrs='': [] - ) - monkeypatch.setattr( - "webpack_loader.utils.get_files", - lambda entry, extension=None, config='DEFAULT', attrs='': [] - ) diff --git a/cms/envs/test.py b/cms/envs/test.py index 1e249f18d0..9a294bf10b 100644 --- a/cms/envs/test.py +++ b/cms/envs/test.py @@ -70,6 +70,7 @@ TEST_ROOT = path("test_root") # Want static files in the same dir for running on jenkins. STATIC_ROOT = TEST_ROOT / "staticfiles" WEBPACK_LOADER["DEFAULT"]["STATS_FILE"] = STATIC_ROOT / "webpack-stats.json" +WEBPACK_LOADER['DEFAULT']['LOADER_CLASS'] = 'webpack_loader.loader.FakeWebpackLoader' GITHUB_REPO_ROOT = TEST_ROOT / "data" DATA_DIR = TEST_ROOT / "data" diff --git a/conftest.py b/conftest.py index 066af9c8e3..3fc522a969 100644 --- a/conftest.py +++ b/conftest.py @@ -15,19 +15,3 @@ from cms.conftest import _django_clear_site_cache, pytest_configure # pylint: d # When using self.assertEquals, diffs are truncated. We don't want that, always # show the whole diff. TestCase.maxDiff = None - - -@pytest.fixture(autouse=True) -def no_webpack_loader(monkeypatch): # lint-amnesty, pylint: disable=missing-function-docstring - monkeypatch.setattr( - "webpack_loader.templatetags.webpack_loader.render_bundle", - lambda context, entry, extension=None, config='DEFAULT', attrs='': '' - ) - monkeypatch.setattr( - "webpack_loader.utils.get_as_tags", - lambda entry, extension=None, config='DEFAULT', attrs='': [] - ) - monkeypatch.setattr( - "webpack_loader.utils.get_files", - lambda entry, extension=None, config='DEFAULT', attrs='': [] - ) diff --git a/lms/envs/test.py b/lms/envs/test.py index c2b2b15569..958a54be01 100644 --- a/lms/envs/test.py +++ b/lms/envs/test.py @@ -101,6 +101,7 @@ TEST_ROOT = path("test_root") # Want static files in the same dir for running on jenkins. STATIC_ROOT = TEST_ROOT / "staticfiles" WEBPACK_LOADER['DEFAULT']['STATS_FILE'] = STATIC_ROOT / "webpack-stats.json" +WEBPACK_LOADER['DEFAULT']['LOADER_CLASS'] = 'webpack_loader.loader.FakeWebpackLoader' STATUS_MESSAGE_PATH = TEST_ROOT / "status_message.json"