def test_scan_cannot_access_base_dir(self): with self.assertRaises(NoPermissionsForBasePathError): with self.temp_file_structure('', ( ('DIR', 'no_traverse_dir', '#notraverse'), ('DIR', 'no_traverse_dir/subdir'), )): scan_files(self.resolve_test_path('no_traverse_dir/subdir'))
def test_abort(self): with self.assertRaises(ScanFilesAbortedError): with self.temp_file_structure('', self.BASIC_FILE_STRUCTURE): scan_files( base_path=self.resolve_test_path(''), recursive=True, check_abort=abort_after_n_calls(len(self.BASIC_FILE_STRUCTURE) // 2), )
def test_reports_progress(self): with self.verify_reported_progress() as on_progress: with self.temp_file_structure('', self.BASIC_FILE_STRUCTURE): scan_files( base_path=self.resolve_test_path(''), recursive=True, on_progress=on_progress, )
def _recompute_async_impl(self, check_abort, base_path, scan_recursive): return scan_files( base_path, scan_recursive, on_progress=self._on_async_progress, check_abort=check_abort, )
def _test_scan_files(self, setup_files=None, expected_result=None, **options): with self.temp_file_structure('', setup_files): files = scan_files(self.resolve_test_path(''), **options) self.assertEqual( normalize_unicode(tuple(f.test_repr() for f in files)), normalize_unicode(expected_result), )
def test_scan_cannot_explore(self): with self.assertRaises(NoPermissionsForBasePathError): with self.temp_file_structure('', ( ('DIR', 'no_read_dir', '#noread'), )): scan_files(self.resolve_test_path('no_read_dir'))
def test_scan_base_path_not_a_dir(self): with self.assertRaises(BasePathIsNotADirectoryError): with self.temp_file_structure('', ( ('FILE', 'file1'), )): scan_files(self.resolve_test_path('file1'))
def test_scan_non_existent(self): with self.assertRaises(BasePathDoesNotExistError): scan_files(self.resolve_test_path('non_existent'))
def _rescan_files(self): return tuple(f.test_repr() for f in scan_files(self.resolve_test_path(''), recursive=True))