fix: publish shared capa fixtures from a testing package - #286
fix: publish shared capa fixtures from a testing package#286AhtishamShahid wants to merge 1 commit into
Conversation
|
Thanks for the pull request, @AhtishamShahid! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Not for merge. The previous commit pinned the released 1.0.3 and CI failed
across every unit-test shard with
ModuleNotFoundError: No module named 'xblocks_contrib.problem.capa.tests'
because no 1.0.x wheel ships the shared capa fixtures this repo imports from
its own test suite.
This commit repoints the requirement at the branch behind
openedx/xblocks-core#286, which fixes that packaging bug, so CI can
demonstrate that the version bump is otherwise clean.
Revert to a released pin (1.0.4) once edly-io#286 is merged and released.
|
Downstream verification: openedx/openedx-platform#38960 demonstrates both sides of this. Its first commit pins the released 1.0.3 and every unit-test shard fails at collection with That PR is parked in draft until this one is merged and released. |
16cd54f to
f7575a3
Compare
openedx/xblocks-core#286 moves the capa fixtures this repo imports out of `xblocks_contrib.problem.capa.tests` and into a `capa.testing` package that actually ships in the wheel: capa.tests.response_xml_factory -> capa.testing.response_xml_factory capa.tests.test_util.UseUnsafeCodejail -> capa.testing.codejail.UseUnsafeCodejail Update all 17 importers accordingly, and move the VCS reference to that PR's latest commit. Verified with the resulting wheel installed: the previously-erroring modules collect cleanly (1281 tests collected, 0 errors) and xmodule/tests/test_capa_block.py passes 201/201.
f7575a3 to
dd39587
Compare
…ixup No functional change; retargets the VCS reference at the amended commit on openedx/xblocks-core#286.
dd39587 to
22a6c1e
Compare
Downstream test suites import capa fixtures from this distribution, but no
1.0.x wheel contains them: `[tool.setuptools.packages.find]`'s `*tests*`
exclusion drops `xblocks_contrib.problem.capa.tests` entirely. MANIFEST.in
tries to hold them back --
# We do this because openedx-platform imports these specific test helpers.
include xblocks_contrib/problem/capa/tests/test_util.py
...
-- but MANIFEST.in only governs the sdist, so the intent never reached the
wheel. openedx-platform consequently fails to collect ~17 of its own test
modules against any 1.0.x release, and stays pinned to 0.17.0.
Move the two fixtures consumers actually import into a `capa/testing/`
package. It is deliberately not under a `tests/` directory, so the existing
exclusion cannot match it -- no packaging configuration changes at all:
* `capa/testing/response_xml_factory.py` -- moved verbatim; a pure factory
module with no tests in it.
* `capa/testing/codejail.py` -- `UseUnsafeCodejail`, lifted out of
`tests/test_util.py`. That module mixes a real test case (`UtilTest`) with a
fixture only consumers use, so it is split rather than moved; `UtilTest`
stays behind.
`capa/tests/helpers.py` stays internal: despite MANIFEST.in listing it, nothing
outside this repo imports it, and its `load_fixture` resolves paths relative to
`tests/test_files`. The now-stale MANIFEST.in block is removed -- one of the
three files it names no longer exists, and none of them need re-including.
Consumers change import paths as follows:
from xblocks_contrib.problem.capa.tests.response_xml_factory import X
-> from xblocks_contrib.problem.capa.testing.response_xml_factory import X
from xblocks_contrib.problem.capa.tests.test_util import UseUnsafeCodejail
-> from xblocks_contrib.problem.capa.testing.codejail import UseUnsafeCodejail
No released 1.0.x wheel exposes the old paths, so nothing installable can break.
22a6c1e to
f532c45
Compare
openedx/xblocks-core#286 moves the capa fixtures this repo imports out of `xblocks_contrib.problem.capa.tests`, which no 1.0.x wheel ships, into a `capa.testing` package that does: capa.tests.response_xml_factory -> capa.testing.response_xml_factory capa.tests.test_util.UseUnsafeCodejail -> capa.testing.codejail.UseUnsafeCodejail Update all 17 importers accordingly.
Picks up the CapaBlock grading fix released in 1.0.3 (openedx/xblocks-core#272), which restores the correct score and graded state for a problem added to a graded subsection when viewed by its author (mitodl/hq#12023). Reverses the pin from 2d315eb. Points at the branch behind openedx/xblocks-core#286 while that is unreleased, because no released 1.0.x wheel ships the capa fixtures this repo's tests import. Becomes `xblocks-contrib==1.0.4` once edly-io#286 is released.
openedx/xblocks-core#286 moves the capa fixtures this repo imports out of `xblocks_contrib.problem.capa.tests`, which no 1.0.x wheel ships, into a `capa.testing` package that does: capa.tests.response_xml_factory -> capa.testing.response_xml_factory capa.tests.test_util.UseUnsafeCodejail -> capa.testing.codejail.UseUnsafeCodejail Update all 17 importers accordingly.
Picks up the CapaBlock grading fix released in 1.0.3 (openedx/xblocks-core#272), which restores the correct score and graded state for a problem added to a graded subsection when viewed by its author (mitodl/hq#12023). Reverses the pin from 2d315eb. Points at the branch behind openedx/xblocks-core#286 while that is unreleased, because no released 1.0.x wheel ships the capa fixtures this repo's tests import. Becomes `xblocks-contrib==1.0.4` once edly-io#286 is released.
Picks up the CapaBlock grading fix released in 1.0.3 (openedx/xblocks-core#272), which restores the correct score and graded state for a problem added to a graded subsection when viewed by its author. Reverses the pin from 2d315eb. Points at the branch behind openedx/xblocks-core#286 while that is unreleased, because no released 1.0.x wheel ships the capa fixtures this repo's tests import. Becomes `xblocks-contrib==1.0.4` once edly-io#286 is released.
openedx/xblocks-core#286 moves the capa fixtures this repo imports out of `xblocks_contrib.problem.capa.tests`, which no 1.0.x wheel ships, into a `capa.testing` package that does: capa.tests.response_xml_factory -> capa.testing.response_xml_factory capa.tests.test_util.UseUnsafeCodejail -> capa.testing.codejail.UseUnsafeCodejail Update all 17 importers accordingly.
Picks up the CapaBlock grading fix released in 1.0.3 (openedx/xblocks-core#272), which restores the correct score and graded state for a problem added to a graded subsection when viewed by its author. Reverses the pin from 2d315eb. Points at the branch behind openedx/xblocks-core#286 while that is unreleased, because no released 1.0.x wheel ships the capa fixtures this repo's tests import. Becomes `xblocks-contrib==1.0.4` once edly-io#286 is released.
The problem
openedx-platform imports capa test fixtures from this package in 17 of its own test modules. No 1.0.x wheel contains them, so those modules fail at collection:
The cause is that two different files decide two different artifacts:
MANIFEST.inre-includes the fixtures, and says exactly the right thing about why — "We do this because openedx-platform imports these specific test helpers" — but it only governs the sdist.[tool.setuptools.packages.find], whoseexclude = ["*tests*"](added in Modernize Python repo: pyproject.toml + uv + semantic-release #251) drops the wholecapa.testspackage.So the sdist has the fixtures, the wheel does not, and consumers install the wheel.
That is why openedx-platform is pinned back to 0.17.0 (openedx-platform@2d315ebd69) and why no 1.0.x release can reach a deployment — including the grading fix from #272, which course teams are still waiting on: a problem added to a graded subsection displays as
0 points / ungradedto the author who created it, while every other user sees it correctly.The fix
Move the two fixtures consumers actually import into a
capa/testing/package. It is deliberately not under atests/directory, so the existing exclusion cannot match it — no packaging configuration changes at all.response_xml_factory.pycapa/testing/response_xml_factory.py— pure rename, zero content changeUseUnsafeCodejailcapa/testing/codejail.pyhelpers.pyTwo details worth knowing:
tests/test_util.pymixes a real test case (UtilTest) withUseUnsafeCodejail, which only consumers use — so it is split, not moved.UtilTeststays put.helpers.pydoes not move despite itsMANIFEST.inentry: nothing outside this repo imports it, and itsload_fixtureresolves paths relative totests/test_files. The staleMANIFEST.inblock is removed — one of the three files it names no longer exists, and none of them need re-including.Verification
capa/testing/modules and zerotests/files.xmodule/tests/test_capa_block.pypasses 201/201.Progress(0, 1)instead ofNone.For consumers
xblock_problem.capa.tests.*, which would hit this same exclusion — becomes.testing.*once this lands. Happy to push that.fix:(patch), since no released 1.0.x wheel exposes the old paths so nothing installable can break. Tell me if you'd rather this beBREAKING CHANGE:→ 2.0.0 and I'll amend.Deliberately not included
Kept out to keep this reviewable as a single fix — happy to follow up on any of them:
capa/testing/being silently re-excluded by a future glob edit —exclude = ["*test*"], one character shorter, would do it.xblock_pdf/js_tests/is shipped in released wheels (vitest config, tsconfig, spec helpers) — a pre-existing leak, unrelated to this bug.six(capa/inputtypes.py,capa/responsetypes.py),symmath(capa/responsetypes.py), andweb_fragments(xblock_pdf/pdf.py+ 8 others). They work only because installers pull them in transitively.Merge checklist:
Check off if complete or not applicable:
fix:)testing/__init__.pyThis PR was created using Claude Opus 5