示例#1
0
def test_find_modules_errors():
    with pytest.raises(TypeError):
        list(util.find_modules(1))

    with pytest.raises(TypeError):
        list(util.find_modules(None))

    with pytest.raises(TypeError):
        list(util.find_modules('foo', 1))
示例#2
0
def test_find_modules(modules_system):
    # The test modules will be found as many times as there are partitions and
    # environments in the current system
    current_system = rt.runtime().system
    ntimes = sum(len(p.environs) for p in current_system.partitions)

    found_modules = [m[2] for m in util.find_modules('testmod')]
    if modules_system.name == 'nomod':
        assert found_modules == []
    else:
        assert found_modules == ['testmod_bar', 'testmod_base', 'testmod_boo',
                                 'testmod_ext', 'testmod_foo']*ntimes
示例#3
0
def test_find_modules_env_mapping(modules_system):
    # The test modules will be found as many times as there are partitions and
    # environments in the current system
    current_system = rt.runtime().system
    ntimes = sum(len(p.environs) for p in current_system.partitions)

    found_modules = [
        m[2] for m in util.find_modules('testmod',
                                        environ_mapping={
                                            r'.*_ba.*': 'builtin',
                                            r'testmod_foo': 'foo'
                                        })
    ]
    if modules_system.name == 'nomod':
        assert found_modules == []
    else:
        assert found_modules == ['testmod_bar', 'testmod_base'] * ntimes