self.assertEqual(added, False)
        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'))


# =========================================
#       MAIN
# --------------------------------------

if __name__ == '__main__':
    helper.run(TestCase)
示例#2
0
import sys
import os

from os import path

CURRENT_PATH = path.abspath(path.dirname(__file__))

if path.isdir(__file__):
    ROOT_PATH = path.abspath(path.join(CURRENT_PATH, '..'))
else:
    ROOT_PATH = path.abspath(path.join(CURRENT_PATH, '..', '..'))

try:
    try:
        sys.path.remove(CURRENT_PATH)
    except:
        pass

    sys.path.index(ROOT_PATH)

except ValueError:
    sys.path.insert(0, ROOT_PATH)

from rootpath.tests import helper

# =========================================
#       MAIN
# --------------------------------------

helper.run(__file__)