From 9de24c0417be4277354af4322dd174a38e8d1785 Mon Sep 17 00:00:00 2001 From: Sebastiaan Zeeff <33516116+SebastiaanZ@users.noreply.github.com> Date: Mon, 14 Oct 2019 14:48:18 +0200 Subject: Migrate test_constants to unittest Migrates the `test_constants.py` file to unittest. As with the pytest version, there is not yet support to test container types. --- tests/bot/test_constants.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/bot/test_constants.py (limited to 'tests') diff --git a/tests/bot/test_constants.py b/tests/bot/test_constants.py new file mode 100644 index 000000000..dae7c066c --- /dev/null +++ b/tests/bot/test_constants.py @@ -0,0 +1,26 @@ +import inspect +import unittest + +from bot import constants + + +class ConstantsTests(unittest.TestCase): + """Tests for our constants.""" + + def test_section_configuration_matches_type_specification(self): + """The section annotations should match the actual types of the sections.""" + + sections = ( + cls + for (name, cls) in inspect.getmembers(constants) + if hasattr(cls, 'section') and isinstance(cls, type) + ) + for section in sections: + for name, annotation in section.__annotations__.items(): + with self.subTest(section=section, name=name, annotation=annotation): + value = getattr(section, name) + + if getattr(annotation, '_name', None) in ('Dict', 'List'): + self.skipTest("Cannot validate containers yet.") + + self.assertIsInstance(value, annotation) -- cgit v1.2.3