diff options
| author | John L. Villalovos <john@sodarock.com> | 2022-01-22 10:56:19 -0800 |
|---|---|---|
| committer | John L. Villalovos <john@sodarock.com> | 2022-01-22 10:56:19 -0800 |
| commit | 9c8c8043e6d1d9fadb9f10d47d7f4799ab904e9c (patch) | |
| tree | 17228ec0ff1daf364319a2a2b368c35bd61ea494 | |
| parent | 8dfed0c362af2c5e936011fd0b488b8b05e8a8a0 (diff) | |
| download | gitlab-9c8c8043e6d1d9fadb9f10d47d7f4799ab904e9c.tar.gz | |
test: add a meta test to make sure that v4/objects/ files are imported
Add a test to make sure that all of the `gitlab/v4/objects/` files are
imported in `gitlab/v4/objects/__init__.py`
| -rw-r--r-- | tests/meta/test_v4_objects_imported.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/meta/test_v4_objects_imported.py b/tests/meta/test_v4_objects_imported.py new file mode 100644 index 0000000..083443a --- /dev/null +++ b/tests/meta/test_v4_objects_imported.py @@ -0,0 +1,32 @@ +""" +Ensure objects defined in gitlab.v4.objects are imported in +`gitlab/v4/objects/__init__.py` + +""" +import pkgutil +from typing import Set + +import gitlab.v4.objects + + +def test_verify_v4_objects_imported() -> None: + assert len(gitlab.v4.objects.__path__) == 1 + + init_files: Set[str] = set() + with open(gitlab.v4.objects.__file__, "r") as in_file: + for line in in_file.readlines(): + if line.startswith("from ."): + init_files.add(line.rstrip()) + + object_files = set() + for module in pkgutil.iter_modules(gitlab.v4.objects.__path__): + object_files.add(f"from .{module.name} import *") + + missing_in_init = object_files - init_files + error_message = ( + f"\nThe file {gitlab.v4.objects.__file__!r} is missing the following imports:" + ) + for missing in sorted(missing_in_init): + error_message += f"\n {missing}" + + assert not missing_in_init, error_message |
