mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 08:58:36 +00:00
conftest: install the piecewise finder before the translator is imported
test_support_installs_the_finder_only_where_the_tokenizer_is_slow is the one test keeping the CI workflow red on85ec1d33b, and it is red for a reason that has nothing to do with the translator: AssertionError: <class '_frozen_importlib_external.SourceFileLoader'> is not <class 'support.PiecewiseLoader'> support.py installs ToolsFinder just before PathFinder and then imports rdna2spirv through it, but tests/conftest.py imports rdna2spirv first, for its own fixtures. A finder can only take an import it is in sys.meta_path for, so under pytest the module is loaded by PathFinder and stays that way; run as `python tests/test_piecewise_parse.py` there is no conftest and the test passes. Green one way, red the other, for the same code. So conftest now puts tests/semantic on the path and imports support first. support.py imports rdna2spirv itself, so the line after it stays as it is and becomes the import that already happened. Measured, main85ec1d33b, this machine (CPython 3.14, where needed() is true): python -m pytest tests/test_piecewise_parse.py 1 failed, 25 passed -> 26 passed python tests/test_piecewise_parse.py OK, still the five files ci.yml runs for this area + test_cpu_ref 81 passed, 34 skipped Written with an AI assistant.
This commit is contained in:
@ -17,6 +17,16 @@ import pytest
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.insert(0, os.path.join(ROOT, "tools"))
|
||||
|
||||
sys.path.insert(0, os.path.join(ROOT, "tests", "semantic"))
|
||||
# Before rdna2spirv is imported: support.py installs its piecewise finder first
|
||||
# where the tokenizer needs it (Python 3.12 to 3.14.7), and the finder can only
|
||||
# take the import if it is in sys.meta_path when the module is first asked for.
|
||||
# Without this, pytest's conftest imports it through PathFinder and
|
||||
# test_support_installs_the_finder_only_where_the_tokenizer_is_slow sees the
|
||||
# usual loader; run as `python tests/test_piecewise_parse.py` there is no
|
||||
# conftest, which is why the same test passed one way and not the other.
|
||||
import support # noqa: E402, F401
|
||||
|
||||
import mc_command # noqa: E402
|
||||
import rdna2spirv # noqa: E402
|
||||
|
||||
|
||||
Reference in New Issue
Block a user