Skip to content

Import-related mdtests aren't isolated #15027

@dcreager

Description

@dcreager

When testing #15026 I got spurious test failures that look like the different test cases within an mdtest file aren't as isolated as they should be:

At commit 65da139, the Relative - Dotted test fails when you test the entire file:

$ cargo test -p red_knot_python_semantic -- mdtest__import_relative
[snip]
relative.md - Relative - Dotted
  crates/red_knot_python_semantic/resources/mdtest/import/relative.md:39 unexpected error: [unresolved-import] "Cannot resolve import `.foo.bar.baz`"
  crates/red_knot_python_semantic/resources/mdtest/import/relative.md:41 unmatched assertion: revealed: Literal[42]
  crates/red_knot_python_semantic/resources/mdtest/import/relative.md:41 unexpected error: 1 [revealed-type] "Revealed type is `Unknown`"

but pass when you run that test by itself:

$ env MDTEST_TEST_FILTER="relative.md - Relative - Dotted" cargo test -p red_knot_python_semantic -- mdtest__import_relative

Renaming the files in that one test case to be unique within the mdtest file (c5fd3c6) also causes test to pass for both invocations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtestingRelated to testing Ruff itselftyMulti-file analysis & type inference

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions