Skip to content

Commit

Permalink
Fix test_find_sources when run under site-packages (#10075)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JukkaL committed Feb 11, 2021
1 parent 6d7beb4 commit 9517284
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion mypy/test/test_find_sources.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from mypy.modulefinder import BuildSource
import os
import pytest
import shutil
import tempfile
import unittest
from typing import List, Optional, Set, Tuple

from mypy.find_sources import InvalidSourceList, SourceFinder, create_source_list
from mypy.fscache import FileSystemCache
from mypy.modulefinder import BuildSource
from mypy.options import Options
from mypy.modulefinder import BuildSource


class FakeFSCache(FileSystemCache):
Expand Down Expand Up @@ -60,6 +63,15 @@ def find_sources(


class SourceFinderSuite(unittest.TestCase):
def setUp(self) -> None:
self.tempdir = tempfile.mkdtemp()
self.oldcwd = os.getcwd()
os.chdir(self.tempdir)

def tearDown(self) -> None:
os.chdir(self.oldcwd)
shutil.rmtree(self.tempdir)

def test_crawl_no_namespace(self) -> None:
options = Options()
options.namespace_packages = False
Expand Down

0 comments on commit 9517284

Please sign in to comment.