Summary
The test test_shim_include_override_additional_import in numbast/src/numbast/experimental/mlir/tools/tests/test_shim_include_override.py has two weak assertions that can produce false positives:
os_is_imported is set to True for any line starting with "import", not specifically import os. Other generated imports could satisfy this check even if os was never imported.
shim_include line is never required to be present — the test only asserts "os" in line if such a line is found, but never fails if no shim_include line is emitted at all. This means the shim include override behavior could be silently broken.
Proposed Fix
- Change the import check to detect specifically
import os (e.g., line.strip() == "import os" or line.strip().startswith("from os import")).
- Introduce a
shim_include_found flag and assert it is True after the loop, so the test fails if the shim include override line is not emitted.
References
Requested by @isVoid.
Summary
The test
test_shim_include_override_additional_importinnumbast/src/numbast/experimental/mlir/tools/tests/test_shim_include_override.pyhas two weak assertions that can produce false positives:os_is_importedis set toTruefor any line starting with"import", not specificallyimport os. Other generated imports could satisfy this check even ifoswas never imported.shim_includeline is never required to be present — the test only asserts"os" in lineif such a line is found, but never fails if noshim_includeline is emitted at all. This means the shim include override behavior could be silently broken.Proposed Fix
import os(e.g.,line.strip() == "import os"orline.strip().startswith("from os import")).shim_include_foundflag and assert it isTrueafter the loop, so the test fails if the shim include override line is not emitted.References
Requested by @isVoid.