File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ """
2+ Ensure objects defined in gitlab.v4.objects are imported in
3+ `gitlab/v4/objects/__init__.py`
4+
5+ """
6+ import os
7+ import pkgutil
8+ from typing import Set
9+
10+ import gitlab .v4 .objects
11+
12+
13+ def test_verify_v4_objects_imported () -> None :
14+ assert len (gitlab .v4 .objects .__path__ ) == 1
15+
16+ init_files : Set [str ] = set ()
17+ with open (gitlab .v4 .objects .__file__ , "r" ) as in_file :
18+ for line in in_file .readlines ():
19+ if line .startswith ("from ." ):
20+ init_files .add (line .rstrip ())
21+
22+ object_files = set ()
23+ for module in pkgutil .iter_modules (gitlab .v4 .objects .__path__ ):
24+ object_files .add (f"from .{ module .name } import *" )
25+
26+ missing_in_init = object_files - init_files
27+ error_message = (
28+ f"\n The file { gitlab .v4 .objects .__file__ !r} is missing the following imports:"
29+ )
30+ for missing in sorted (missing_in_init ):
31+ error_message += f"\n { missing } "
32+
33+ assert not missing_in_init , error_message
You can’t perform that action at this time.
0 commit comments