def test_rootpath_detect_base(self): root_path = rootpath.detect() self.assertEqual(root_path, ROOT_PATH) root_path = rootpath.detect(helper.fixture_path('projects/null')) self.assertEqual(root_path, ROOT_PATH)
def test_rootpath_detect_entry_nested(self): bar_root_path = helper.fixture_path('projects/py-foo/vendor/py-bar') root_path = rootpath.detect( helper.fixture_path('projects/py-foo/vendor/py-bar')) self.assertEqual(root_path, bar_root_path) root_path = rootpath.detect( helper.fixture_path('projects/py-foo/vendor/py-bar/')) self.assertEqual(root_path, bar_root_path) root_path = rootpath.detect( helper.fixture_path('projects/py-foo/vendor/py-bar/src')) self.assertEqual(root_path, bar_root_path) root_path = rootpath.detect( helper.fixture_path('projects/py-foo/vendor/py-bar/src/')) self.assertEqual(root_path, bar_root_path) root_path = rootpath.detect( helper.fixture_path('projects/py-foo/vendor/py-bar/src/utils')) self.assertEqual(root_path, bar_root_path) root_path = rootpath.detect( helper.fixture_path('projects/py-foo/vendor/py-bar/src/utils/')) self.assertEqual(root_path, bar_root_path)
def test_rootpath_detect_entry_pattern(self): foo_root_path = helper.fixture_path('projects/py-foo') root_path = rootpath.detect(helper.fixture_path('projects/py-foo'), 'not_a_file') self.assertNotEqual(root_path, foo_root_path) root_path = rootpath.detect(helper.fixture_path('projects/py-foo/'), 'not_a_file') self.assertNotEqual(root_path, foo_root_path) root_path = rootpath.detect(helper.fixture_path('projects/py-foo/foo'), 'not_a_file') self.assertNotEqual(root_path, foo_root_path) root_path = rootpath.detect( helper.fixture_path('projects/py-foo/foo/'), 'not_a_file') self.assertNotEqual(root_path, foo_root_path) root_path = rootpath.detect( helper.fixture_path('projects/py-foo/foo/utils'), 'not_a_file') self.assertNotEqual(root_path, foo_root_path) root_path = rootpath.detect( helper.fixture_path('projects/py-foo/foo/utils/'), 'not_a_file') self.assertNotEqual(root_path, foo_root_path)
def test_rootpath_detect_entry(self): foo_root_path = helper.fixture_path('projects/py-foo') root_path = rootpath.detect(helper.fixture_path('projects/py-foo')) self.assertEqual(root_path, foo_root_path) root_path = rootpath.detect(helper.fixture_path('projects/py-foo/')) self.assertEqual(root_path, foo_root_path) root_path = rootpath.detect(helper.fixture_path('projects/py-foo/foo')) self.assertEqual(root_path, foo_root_path) root_path = rootpath.detect( helper.fixture_path('projects/py-foo/foo/')) self.assertEqual(root_path, foo_root_path) root_path = rootpath.detect( helper.fixture_path('projects/py-foo/foo/utils')) self.assertEqual(root_path, foo_root_path) root_path = rootpath.detect( helper.fixture_path('projects/py-foo/foo/utils/')) self.assertEqual(root_path, foo_root_path)
def test_rootpath_append_entry_nested(self): BAR_ROOT_PATH = helper.fixture_path('projects/py-foo/vendor/py-bar') try: sys.path.remove(BAR_ROOT_PATH) except: pass added, root_path = rootpath.append(helper.fixture_path('projects/py-foo/vendor/py-bar')) self.assertEqual(added, True) self.assertEqual(root_path, BAR_ROOT_PATH) added, root_path = rootpath.append(helper.fixture_path('projects/py-foo/vendor/py-bar/src')) self.assertEqual(added, False) self.assertEqual(root_path, BAR_ROOT_PATH) added, root_path = rootpath.append(helper.fixture_path('projects/py-foo/vendor/py-bar/src/utils'))
def test_rootpath_append_entry(self): FOO_ROOT_PATH = helper.fixture_path('projects/py-foo') try: sys.path.remove(FOO_ROOT_PATH) except: pass added, root_path = rootpath.append(helper.fixture_path('projects/py-foo')) self.assertEqual(added, True) self.assertEqual(root_path, FOO_ROOT_PATH) added, root_path = rootpath.append(helper.fixture_path('projects/py-foo')) self.assertEqual(added, False) self.assertEqual(root_path, FOO_ROOT_PATH) added, root_path = rootpath.append(helper.fixture_path('projects/py-foo/foo')) self.assertEqual(added, False) self.assertEqual(root_path, FOO_ROOT_PATH) added, root_path = rootpath.append(helper.fixture_path('projects/py-foo/foo')) self.assertEqual(added, False) self.assertEqual(root_path, FOO_ROOT_PATH) added, root_path = rootpath.append(helper.fixture_path('projects/py-foo')) self.assertEqual(added, False) self.assertEqual(root_path, FOO_ROOT_PATH) added, root_path = rootpath.append(helper.fixture_path('projects/py-foo/foo')) self.assertEqual(added, False) self.assertEqual(root_path, FOO_ROOT_PATH) added, root_path = rootpath.append(helper.fixture_path('projects/py-foo/foo/utils')) self.assertEqual(added, False) self.assertEqual(root_path, FOO_ROOT_PATH)
def test_rootpath_detect_entry_nested_pattern(self): bar_root_path = helper.fixture_path('projects/py-foo/vendor/py-bar') root_path = rootpath.detect( helper.fixture_path('projects/py-foo/vendor/py-bar'), 'not_a_file') self.assertEqual(root_path, None) root_path = rootpath.detect( helper.fixture_path('projects/py-foo/vendor/py-bar/'), 'not_a_file') self.assertEqual(root_path, None) root_path = rootpath.detect( helper.fixture_path('projects/py-foo/vendor/py-bar/src'), 'not_a_file') self.assertEqual(root_path, None) root_path = rootpath.detect( helper.fixture_path('projects/py-foo/vendor/py-bar/src/'), 'not_a_file') self.assertEqual(root_path, None) root_path = rootpath.detect( helper.fixture_path('projects/py-foo/vendor/py-bar/src/utils'), 'not_a_file') self.assertEqual(root_path, None) root_path = rootpath.detect( helper.fixture_path('projects/py-foo/vendor/py-bar/src/utils/'), 'not_a_file') self.assertEqual(root_path, None)