8000 Fix test_find_sources when run under site-packages (#10075) · python/mypy@9517284 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9517284

Browse files
authored
Fix test_find_sources when run under site-packages (#10075)
This was failing during wheel builds because we run the tests after installation (under `site-packages`), and this confused the module search logic. Hard code the paths to make this work in any install location.
1 parent 6d7beb4 commit 9517284

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

mypy/test/test_find_sources.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
from mypy.modulefinder import BuildSource
21
import os
32
import pytest
3+
import shutil
4+
import tempfile
45
import unittest
56
from typing import List, Optional, Set, Tuple
7+
68
from mypy.find_sources import InvalidSourceList, SourceFinder, create_source_list
79
from mypy.fscache import FileSystemCache
810
from mypy.modulefinder import BuildSource
911
from mypy.options import Options
12+
from mypy.modulefinder import BuildSource
1013

1114

1215
class FakeFSCache(FileSystemCache):
@@ -60,6 +63,15 @@ def find_sources(
6063

6164

6265
class SourceFinderSuite(unittest.TestCase):
66+
def setUp(self) -> None:
67+
self.tempdir = tempfile.mkdtemp()
68+
self.oldcwd = os.getcwd()
69+
os.chdir(self.tempdir)
70+
71+
def tearDown(self) -> None:
72+
os.chdir(self.oldcwd)
73+
shutil.rmtree(self.tempdir)
74+
6375
def test_crawl_no_namespace(self) -> None:
6476
options = Options()
6577
options.namespace_packages = False

0 commit comments

Comments
 (0)
0