def test_triangle_deps(self): triangle_deps = { "/home/badger/a.ts": "import b = require('./b.ts');\nimport c = require('./c.ts');", "/home/badger/b.ts": "import c = require('./c.ts');", "/home/badger/c.ts": "", } import_resolver.read_file = lambda x: triangle_deps[x] expected_string = "\n".join( [ "/home/badger/c.ts <- /home/badger/a.ts /home/badger/b.ts", "/home/badger/a.ts <- ", "/home/badger/b.ts <- /home/badger/a.ts", ] ) self.assertEqual(import_resolver.do_dependency_resolve(["/home/badger/a.ts"]), expected_string)
def test_triangle_deps(self): triangle_deps = { "/home/badger/a.ts": "import b = require('./b.ts');\nimport c = require('./c.ts');", "/home/badger/b.ts": "import c = require('./c.ts');", "/home/badger/c.ts": "", } import_resolver.read_file = lambda x: triangle_deps[x] expected_string = "\n".join([ "/home/badger/c.ts <- /home/badger/a.ts /home/badger/b.ts", "/home/badger/a.ts <- ", "/home/badger/b.ts <- /home/badger/a.ts", ]) self.assertEqual( import_resolver.do_dependency_resolve(["/home/badger/a.ts"]), expected_string)
def test_inaccessible_deps(self): def inaccessible_deps(filename): if "a.ts" in filename: return "import b = require('./b.ts');" elif "b.ts" in filename: return "import c = require('./c.ts');" raise IOError import_resolver.read_file = inaccessible_deps expected_string = "\n".join([ "/home/badger/c.ts <- /home/badger/b.ts", "/home/badger/a.ts <- ", "/home/badger/b.ts <- /home/badger/a.ts", "Cannot read file '/home/badger/c.ts'", ]) self.assertEqual( import_resolver.do_dependency_resolve(["/home/badger/a.ts"]), expected_string)
def test_inaccessible_deps(self): def inaccessible_deps(filename): if "a.ts" in filename: return "import b = require('./b.ts');" elif "b.ts" in filename: return "import c = require('./c.ts');" raise IOError import_resolver.read_file = inaccessible_deps expected_string = "\n".join( [ "/home/badger/c.ts <- /home/badger/b.ts", "/home/badger/a.ts <- ", "/home/badger/b.ts <- /home/badger/a.ts", "Cannot read file '/home/badger/c.ts'", ] ) self.assertEqual(import_resolver.do_dependency_resolve(["/home/badger/a.ts"]), expected_string)