Skip to content

Commit f35791e

Browse files
authored
Fix update_lib tests (RustPython#6866)
1 parent e0e2926 commit f35791e

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

scripts/update_lib/tests/test_deps.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,19 @@ def test_syntax_error_returns_empty(self):
6464
class TestGetLibPaths(unittest.TestCase):
6565
"""Tests for get_lib_paths function."""
6666

67-
def test_known_dependency(self):
68-
"""Test library with known dependencies."""
69-
paths = get_lib_paths("datetime", "cpython")
70-
self.assertEqual(len(paths), 2)
71-
self.assertIn(pathlib.Path("cpython/Lib/datetime.py"), paths)
72-
self.assertIn(pathlib.Path("cpython/Lib/_pydatetime.py"), paths)
67+
def test_auto_detect_py_module(self):
68+
"""Test auto-detection of _py{module}.py pattern."""
69+
with tempfile.TemporaryDirectory() as tmpdir:
70+
tmpdir = pathlib.Path(tmpdir)
71+
lib_dir = tmpdir / "Lib"
72+
lib_dir.mkdir()
73+
(lib_dir / "datetime.py").write_text("# datetime")
74+
(lib_dir / "_pydatetime.py").write_text("# _pydatetime")
75+
76+
paths = get_lib_paths("datetime", str(tmpdir))
77+
self.assertEqual(len(paths), 2)
78+
self.assertIn(tmpdir / "Lib" / "datetime.py", paths)
79+
self.assertIn(tmpdir / "Lib" / "_pydatetime.py", paths)
7380

7481
def test_default_file(self):
7582
"""Test default to .py file."""

0 commit comments

Comments
 (0)