How to use the importlab.fs function in importlab

To help you get started, we’ve selected a few importlab examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github google / importlab / tests / test_resolve.py View on Github external
def testInferModuleName(self):
        with utils.Tempdir() as d:
            os_fs = fs.OSFileSystem(d.path)
            fspath = [os_fs]
            py_file = d.create_file("foo/bar.py")
            self.assertEqual(
                    resolve.infer_module_name(py_file, fspath),
                    "foo.bar")
            # Standalone Python scripts often don't have extensions.
            self.assertEqual(
                    resolve.infer_module_name(d["foo/baz"], fspath),
                    "foo.baz")
            self.assertEqual(
                    resolve.infer_module_name(d["random/src.py"], fspath),
                    "random.src")
            self.assertEqual(
                    resolve.infer_module_name("/some/random/file", fspath),
                    "")
github google / importlab / tests / test_output.py View on Github external
def setUp(self):
        self.tempdir = utils.Tempdir()
        self.tempdir.setup()
        filenames = [
            self.tempdir.create_file(f, FILES[f])
            for f in FILES]
        self.fs = fs.OSFileSystem(self.tempdir.path)
        env = environment.Environment(fs.Path([self.fs]), (3, 6))
        self.graph = graph.ImportGraph.create(env, filenames)
github google / importlab / tests / test_graph.py View on Github external
def setUp(self):
        self.tempdir = utils.Tempdir()
        self.tempdir.setup()
        self.filenames = [
            self.tempdir.create_file(f, FILES[f])
            for f in FILES]
        self.fs = fs.OSFileSystem(self.tempdir.path)
        self.env = environment.Environment(fs.Path([self.fs]), (3, 6))
github google / importlab / tests / test_graph.py View on Github external
def setUp(self):
        self.tempdir = utils.Tempdir()
        self.tempdir.setup()
        self.filenames = [
            self.tempdir.create_file(f, FILES[f])
            for f in FILES]
        self.fs = fs.OSFileSystem(self.tempdir.path)
        self.env = environment.Environment(fs.Path([self.fs]), (3, 6))
github google / importlab / tests / test_fs.py View on Github external
def testNoTrivialEmptyDir(self):
        f = fs.StoredFileSystem({"foo/a.py": True, "bar/b.py": True})
        self.assertTrue(f.isdir("foo"))
        self.assertTrue(f.isdir("bar"))
        self.assertFalse(f.isdir(""))
github google / importlab / tests / test_resolve.py View on Github external
def setUp(self):
        self.py_fs = fs.StoredFileSystem(FILES)
        self.pyi_fs = fs.PYIFileSystem(fs.StoredFileSystem(PYI_FILES))
        self.path = [self.pyi_fs, self.py_fs]
github google / importlab / tests / test_fs.py View on Github external
def tearDown(self):
        self.tempdir.teardown()

    def testIsFile(self):
        self.assertTrue(self.fs.isfile("a.py"))
        self.assertTrue(self.fs.isfile("foo/c.py"))
        self.assertFalse(self.fs.isfile("foo/b.py"))

    def testIsDir(self):
        self.assertTrue(self.fs.isdir("foo"))
        self.assertTrue(self.fs.isdir(""))
        self.assertFalse(self.fs.isdir("foo/c.py"))
        self.assertFalse(self.fs.isdir("a.py"))


class LowercasingFileSystem(fs.RemappingFileSystem):
    """Remapping file system subclass for tests."""

    def map_path(self, path):
        return path.lower()


class TestRemappingFileSystem(unittest.TestCase):
    """Tests for RemappingFileSystem."""

    def setUp(self):
        self.tempdir = utils.Tempdir()
        self.tempdir.setup()
        for f in FILES:
            self.tempdir.create_file(f, FILES[f])
        self.fs = LowercasingFileSystem(
                fs.OSFileSystem(self.tempdir.path))