From 8e03e15fd677f42fd4c670743435a8689de55cc7 Mon Sep 17 00:00:00 2001 From: Jay Bazuzi Date: Sun, 10 Nov 2024 19:02:53 -0800 Subject: [PATCH] . t dynamically discover the approvals modules --- ..._options.test_list_of_modules.approved.txt | 6 ++++++ tests/test_options.py | 21 ++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 tests/approved_files/test_options.test_list_of_modules.approved.txt diff --git a/tests/approved_files/test_options.test_list_of_modules.approved.txt b/tests/approved_files/test_options.test_list_of_modules.approved.txt new file mode 100644 index 0000000..4a0d115 --- /dev/null +++ b/tests/approved_files/test_options.test_list_of_modules.approved.txt @@ -0,0 +1,6 @@ +0) approvaltests.approvals +1) approvaltests.combination_approvals +2) approvaltests.integrations.mrjob.mrjob_approvals +3) approvaltests.utilities.command_line_approvals +4) approvaltests.utilities.logger.simple_logger_approvals +5) approvaltests.utilities.logging.logging_approvals diff --git a/tests/test_options.py b/tests/test_options.py index c2af144..6c23f48 100644 --- a/tests/test_options.py +++ b/tests/test_options.py @@ -1,9 +1,12 @@ +import importlib import inspect +import sys from approvaltests import ( get_default_reporter, approvals, verify, + verify_all, ReporterForTesting, combination_approvals, ) @@ -13,14 +16,22 @@ from approvaltests.reporters.report_with_beyond_compare import ReportWithPycharm from approvaltests.utilities import command_line_approvals from approvaltests.utilities.logger import simple_logger_approvals +from approvaltests.utilities.logging import logging_approvals + + +_approvals_modules = list(sorted(filter( + lambda name: name.startswith("approvaltests.") and name.endswith("approvals"), + sys.modules.keys(), +))) + + +def test_list_of_modules(): + verify_all("", _approvals_modules) def test_every_function_in_approvals_with_verify_has_an_options(): - assert_verify_methods_have_options(approvals) - assert_verify_methods_have_options(combination_approvals) - assert_verify_methods_have_options(simple_logger_approvals) - assert_verify_methods_have_options(command_line_approvals) - assert_verify_methods_have_options(mrjob_approvals) + for module_name in _approvals_modules: + assert_verify_methods_have_options(importlib.import_module(module_name)) def assert_verify_methods_have_options(module):