Beispiel #1
0
def test_module_loader_loads_everything_on_empty_filters_no_recursion(load_dir, dir_prop_list):
    mg = aop_gatherer.ModuleGatherer(recursive=False)
    all_paths = [load_dir.join(k) for k in dir_prop_list.keys()]
    required_paths = [str(i) for i in all_paths if i.dirname == load_dir.realpath()]
    modules = mg.load_modules(str(load_dir))
    module_files = [m.__file__ for m in modules]
    assert sorted(required_paths) == sorted(module_files)
Beispiel #2
0
def test_module_loader_default_does_not_load_privates(load_dir_with_privates, dir_prop_list_with_privates):
    #TODO: this consistently fails when run in a group, consistently works when running on its own.
    #       This seems to be caused by the tests running in the same environemnt.
    #       The directory creation creates a new tempdir for load_dir_with_privates, but most imported libs have the
    #       same name, therefore exist in sys.modules and are therefore brought from the old files.
    _reset_sys_modules(dir_prop_list_with_privates.keys())
    mg = aop_gatherer.ModuleGatherer(recursive=True)
    required_paths = [str(load_dir_with_privates.join(k)) for k in dir_prop_list_with_privates.keys()
                      if 'private' not in str(k)]
    modules = mg.load_modules(str(load_dir_with_privates))

    module_files = [m.__file__ for m in modules]
    assert sorted(required_paths) == sorted(module_files)
Beispiel #3
0
def test_module_loader_loads_according_to_name_filter(load_dir, dir_prop_list, special_module_matcher_filename):
    mg = aop_gatherer.ModuleGatherer((lambda x: x.name == special_module_matcher_filename,), recursive=True)
    a = mg.load_modules(str(load_dir))
    assert [i.__file__ for i in a] == [load_dir.join(special_module_matcher_filename).realpath()]
Beispiel #4
0
def test_module_loader_loads_everything_on_empty_filters_with_recursion(load_dir, dir_prop_list):
    mg = aop_gatherer.ModuleGatherer(recursive=True)
    required_paths = [str(load_dir.join(k)) for k in dir_prop_list.keys()]
    modules = mg.load_modules(str(load_dir))
    module_files = [m.__file__ for m in modules]
    assert sorted(required_paths) == sorted(module_files)
Beispiel #5
0
def test_module_loader_loads_according_to_all_module_filters(load_dir, dir_prop_list, file_properties):
    mg = aop_gatherer.ModuleGatherer(module_filters=tuple(lambda m: hasattr(m, i) for i in file_properties['properties']),
        recursive=True)
    required_paths = [str(load_dir.join(p)) for p, props in dir_prop_list.items() if props == file_properties]

    assert sorted(required_paths) == sorted(m.__file__ for m in mg.load_modules(str(load_dir)))