def test_it_should_ignore_unexplorable_dirs(self, tmpdir): unexplorable_dir = str(tmpdir) os.chmod(unexplorable_dir, 0o444) found = find(unexplorable_dir) assert_that(found, is_(empty()))
def test_it_should_load_full_paths(self, examples): examples.clear() examples.get_many(SORTED_FILES) found = find(str(examples.tmpdir)) assert_that(all(os.path.isabs(path) for path in found), is_(True))
def test_it_should_ignore_unreadable_files(self, examples): unreadable_path = examples.load(FILES[0]) os.chmod(unreadable_path, 0o222) found = find(unreadable_path) assert_that(found, is_(empty()))
def test_it_should_load_files_in_order(self, examples): examples.clear() expected_files = sorted(examples.get_many(SORTED_FILES)) found = find(str(examples.tmpdir)) assert_that(found, is_(expected_files))
def test_it_should_expand_user_variables(self, tmpdir, examples): path = examples.get(FILES[0]) home = os.path.expanduser('~') relpath = os.path.join('~', os.path.relpath(path, start=home)) found = find(relpath) assert_that(found, contains(path))
def test_it_should_warn_about_executable_config_files(self, logger, examples): executable_file = examples.load(FILES[0]) os.chmod(executable_file, 0o777) found = find(executable_file) assert_that(found, contains(executable_file)) logger.warning.assert_called()
def test_it_should_ignore_invalid_files(self): found = find(None) assert_that(found, is_(empty()))
def test_it_should_return_nothing_for_missing_directories(self): assert_that(find('/path/to/nowhere'), is_(empty()))
def test_it_should_load_existing_files(self, examples): path = examples.get(FILES[0]) found = find(path) assert_that(found, contains(path))
def test_it_should_normalize_relative_paths(self): path = os.path.join('.', os.path.basename(__file__)) found = find(path) assert_that(found, contains(__file__))