def test_method_stand_alone():
    rootpath = os.path.join(VALID_ABSPATH, 'root')

    abspath = os.path.join(rootpath, 'valid_module.py')
    eq_(ImportFileMagic._method_stand_alone(abspath), rootpath)

    abspath = os.path.join(rootpath, 'invalid.module.name.py')
    eq_(ImportFileMagic._method_stand_alone(abspath), None)
Beispiel #2
0
def test_method_stand_alone():
    rootpath = os.path.join(VALID_ABSPATH, 'root')

    abspath = os.path.join(rootpath, 'valid_module.py')
    eq_(ImportFileMagic._method_stand_alone(abspath), rootpath)

    abspath = os.path.join(rootpath, 'invalid.module.name.py')
    eq_(ImportFileMagic._method_stand_alone(abspath), None)
def test_has_init():
    rootpath = os.path.join(VALID_ABSPATH, 'root')
    abspath = os.path.join(rootpath, 'a', 'b', 'c.py')
    exists = mock.Mock(return_value=True)
    with mock.patch('os.path.exists', exists):
        assert ImportFileMagic._has_init(abspath, rootpath)

    exists.assert_any_call(os.path.join(rootpath, 'a', 'b', '__init__.py'))
    exists.assert_any_call(os.path.join(rootpath, 'a', '__init__.py'))
    eq_(exists.call_count, 2)
Beispiel #4
0
def test_has_init():
    rootpath = os.path.join(VALID_ABSPATH, 'root')
    abspath = os.path.join(rootpath, 'a', 'b', 'c.py')
    exists = mock.Mock(return_value=True)
    with mock.patch('os.path.exists', exists):
        assert ImportFileMagic._has_init(abspath, rootpath)

    exists.assert_any_call(os.path.join(rootpath, 'a', 'b', '__init__.py'))
    exists.assert_any_call(os.path.join(rootpath, 'a', '__init__.py'))
    eq_(exists.call_count, 2)
def check_is_valid_module_path(subdirs):
    assert isinstance(subdirs, list)
    rootpath = os.path.join(VALID_ABSPATH, 'root')
    abspath = os.path.join(rootpath, *subdirs)
    assert ImportFileMagic._is_valid_module_path(abspath, rootpath)
def check_construct_modulepath(filepath, modulepath):
    rootpath = os.path.join(VALID_ABSPATH, 'root')
    abspath = os.path.join(rootpath, filepath)
    made = ImportFileMagic._construct_modulepath(abspath, rootpath)
    eq_(made, modulepath)
Beispiel #7
0
def check_is_valid_module_path(subdirs):
    assert isinstance(subdirs, list)
    rootpath = os.path.join(VALID_ABSPATH, 'root')
    abspath = os.path.join(rootpath, *subdirs)
    assert ImportFileMagic._is_valid_module_path(abspath, rootpath)
Beispiel #8
0
def check_construct_modulepath(filepath, modulepath):
    rootpath = os.path.join(VALID_ABSPATH, 'root')
    abspath = os.path.join(rootpath, filepath)
    made = ImportFileMagic._construct_modulepath(abspath, rootpath)
    eq_(made, modulepath)