split locate_debugtalk_py to locate_file and convert_module_name

This commit is contained in:
debugtalk
2018-08-09 08:28:21 +08:00
parent 411c6b4428
commit 6c218a1c4f
2 changed files with 56 additions and 33 deletions

View File

@@ -140,38 +140,37 @@ class TestFileLoader(unittest.TestCase):
with self.assertRaises(exceptions.FileNotFound):
loader.load_dot_env_file("not_exist.env")
class TestModuleLoader(unittest.TestCase):
def test_locate_debugtalk_py(self):
def test_locate_file(self):
with self.assertRaises(exceptions.FileNotFound):
loader.locate_debugtalk_py(os.getcwd())
loader.locate_file(os.getcwd(), "debugtalk.py")
with self.assertRaises(exceptions.FileNotFound):
loader.locate_debugtalk_py("")
loader.locate_file("", "debugtalk.py")
start_path = os.path.join(os.getcwd(), "tests")
self.assertEqual(
loader.locate_debugtalk_py(start_path),
"tests.debugtalk"
loader.locate_file(start_path, "debugtalk.py"),
"tests/debugtalk.py"
)
self.assertEqual(
loader.locate_debugtalk_py("tests/"),
"tests.debugtalk"
loader.locate_file("tests/", "debugtalk.py"),
"tests/debugtalk.py"
)
self.assertEqual(
loader.locate_debugtalk_py("tests"),
"tests.debugtalk"
loader.locate_file("tests", "debugtalk.py"),
"tests/debugtalk.py"
)
self.assertEqual(
loader.locate_debugtalk_py("tests/base.py"),
"tests.debugtalk"
loader.locate_file("tests/base.py", "debugtalk.py"),
"tests/debugtalk.py"
)
self.assertEqual(
loader.locate_debugtalk_py("tests/data/test.env"),
"tests.debugtalk"
loader.locate_file("tests/data/test.env", "debugtalk.py"),
"tests/debugtalk.py"
)
class TestModuleLoader(unittest.TestCase):
def test_filter_module_functions(self):
module_mapping = loader.load_python_module(loader)
functions_dict = module_mapping["functions"]