def __test_functionality(module_file, messages_file, dependencies): lint_test = LintTestUpdate() if UPDATE_FILE.exists() else LintTestUsingModule() lint_test.module = module_file.replace(".py", "") lint_test.output = messages_file lint_test.depends = dependencies or None lint_test.INPUT_DIR = INPUT_DIR lint_test._test_functionality()
def test_functional( test_file: FunctionalTestFile, recwarn: WarningsRecorder, pytestconfig: Config ) -> None: __tracebackhide__ = True # pylint: disable=unused-variable if UPDATE_FILE.exists(): lint_test: Union[ LintModuleOutputUpdate, testutils.LintModuleTest ] = LintModuleOutputUpdate(test_file, pytestconfig) else: lint_test = testutils.LintModuleTest(test_file, pytestconfig) lint_test.setUp() lint_test.runTest() warning = None try: # Catch <unknown>:x: DeprecationWarning: invalid escape sequence # so it's not shown during tests warning = recwarn.pop() except AssertionError: pass if warning is not None: if ( test_file.base in TEST_WITH_EXPECTED_DEPRECATION and sys.version_info.minor > 5 ): assert issubclass(warning.category, DeprecationWarning) assert "invalid escape sequence" in str(warning.message)
def test_functional(test_file: FunctionalTestFile, recwarn: WarningsRecorder, pytestconfig: Config) -> None: __tracebackhide__ = True # pylint: disable=unused-variable if UPDATE_FILE.exists(): lint_test: (LintModuleOutputUpdate | testutils.LintModuleTest) = LintModuleOutputUpdate( test_file, pytestconfig) else: lint_test = testutils.LintModuleTest(test_file, pytestconfig) lint_test.setUp() lint_test.runTest() if recwarn.list: if (test_file.base in TEST_WITH_EXPECTED_DEPRECATION and sys.version_info.minor > 5): assert any("invalid escape sequence" in str(i.message) for i in recwarn.list if issubclass(i.category, DeprecationWarning))
def gen_tests(filter_rgx): if filter_rgx: is_to_run = re.compile(filter_rgx).search else: is_to_run = lambda x: 1 # noqa: E731 We're going to throw all this anyway tests = [] for module_file, messages_file in _get_tests_info(INPUT_DIR, MSG_DIR, "func_", ""): if not is_to_run(module_file) or module_file.endswith((".pyc", "$py.class")): continue base = module_file.replace(".py", "").split("_")[1] dependencies = _get_tests_info(INPUT_DIR, MSG_DIR, base, ".py") tests.append((module_file, messages_file, dependencies)) if UPDATE_FILE.exists(): return tests assert len(tests) < 12, "Please do not add new test cases here." + "\n".join( str(k) for k in tests if not k[2] ) return tests
def gen_tests(filter_rgx): if filter_rgx: is_to_run = re.compile(filter_rgx).search else: is_to_run = lambda x: 1 tests = [] for module_file, messages_file in _get_tests_info(INPUT_DIR, MSG_DIR, "func_", ""): if not is_to_run(module_file) or module_file.endswith( (".pyc", "$py.class")): continue base = module_file.replace(".py", "").split("_")[1] dependencies = _get_tests_info(INPUT_DIR, MSG_DIR, base, ".py") tests.append((module_file, messages_file, dependencies)) if UPDATE_FILE.exists(): return tests assert len(tests) < 53, "Please do not add new test cases here." return tests
def test_functional(test_file, recwarn): if UPDATE_FILE.exists(): lint_test = LintModuleOutputUpdate(test_file) else: lint_test = testutils.LintModuleTest(test_file) lint_test.setUp() lint_test._runTest() warning = None try: # Catch <unknown>:x: DeprecationWarning: invalid escape sequence # so it's not shown during tests warning = recwarn.pop() except AssertionError: pass if warning is not None: if (test_file.base in TEST_WITH_EXPECTED_DEPRECATION and sys.version_info.minor > 5): assert issubclass(warning.category, DeprecationWarning) assert "invalid escape sequence" in str(warning.message)
def test_functional(test_file, recwarn): if UPDATE_FILE.exists(): lint_test = LintModuleOutputUpdate(test_file) else: lint_test = testutils.LintModuleTest(test_file) lint_test.setUp() lint_test._runTest() warning = None try: # Catch <unknown>:x: DeprecationWarning: invalid escape sequence # so it's not shown during tests warning = recwarn.pop() except AssertionError: pass if warning is not None: if (test_file.base in TEST_WITH_EXPECTED_DEPRECATION and sys.version_info.minor > 5): assert issubclass(warning.category, DeprecationWarning) assert "invalid escape sequence" in str(warning.message) if __name__ == "__main__": if UPDATE_OPTION in sys.argv: UPDATE_FILE.touch() sys.argv.remove(UPDATE_OPTION) try: pytest.main(sys.argv) finally: if UPDATE_FILE.exists(): UPDATE_FILE.unlink()