def get_user_test_files(test_names, top_level_dir): s = set() for test_spec in test_names: pkgname = get_test_spec_last_pkg(test_spec) if pkgname is None: # This is a top level module mod = test_spec.partition(".")[0] path = os.path.join(top_level_dir, mod + ".py") if os.path.isfile(path): s.add(path) else: path = re.subn(r"\.", "/", pkgname)[0] path = os.path.join(path, "*") s.add(path) return s
def test_error_module(self): actual = get_test_spec_last_pkg("hunittest.test.test_doesnotexists") self.assertEqual("hunittest.test", actual)
def test_module(self): actual = get_test_spec_last_pkg("hunittest.test.test_collectlib") self.assertEqual("hunittest.test", actual)
def test_error_subpkg(self): actual = get_test_spec_last_pkg("hunittest.doesnotexist") self.assertEqual("hunittest", actual)
def test_subpkg(self): actual = get_test_spec_last_pkg("hunittest.test") self.assertEqual("hunittest.test", actual)
def test_error_pkg(self): actual = get_test_spec_last_pkg("doesnotexist") self.assertIsNone(actual)