userver: en/testsuite/plugins/verify_file_paths.py Source File
Loading...
Searching...
No Matches
verify_file_paths.py
1import collections
2
3import pytest
4
5
6@pytest.fixture
7def verify_file_paths(
8 static_dir,
9 _verified_static_dirs,
10 get_all_static_file_paths,
11):
12 def _verify(verifier, check_name, text_at_fail):
13 if check_name in _verified_static_dirs[static_dir]:
14 return
15 failed_paths = [
16 file_path
17 for file_path in get_all_static_file_paths()
18 if not verifier(file_path)
19 ]
20 if failed_paths:
21 pytest.fail(text_at_fail + '\n' + '\n'.join(failed_paths))
22 _verified_static_dirs[static_dir].add(check_name)
23
24 return _verify
25
26
27@pytest.fixture(scope='session')
28def _verified_static_dirs():
29 return collections.defaultdict(set)