Skip to content

Replace hardcoded /tmp paths in test_conflict_shim_names.py with pytest tmp_path fixture #353

Description

@coderabbitai

Summary

In numbast/src/numbast/experimental/mlir/static/tests/test_conflict_shim_names.py, the test_conflict_func_names test writes generated source files to hardcoded /tmp paths:

with open("/tmp/conflict_func_name_1.py", "w") as f:
    f.write(res1["src"])

with open("/tmp/conflict_func_name_2.py", "w") as f:
    f.write(res2["src"])

This can lead to cross-test collisions and makes incorrect assumptions about the target platform (e.g., Windows does not have /tmp).

Suggested Fix

Use pytest's tmp_path fixture to isolate each test run:

def test_conflict_func_names(make_binding, tmp_path):
    ...
    with open(tmp_path / "conflict_func_name_1.py", "w") as f:
        f.write(res1["src"])

    with open(tmp_path / "conflict_func_name_2.py", "w") as f:
        f.write(res2["src"])

References

/cc @isVoid

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions