def inner(base: str) -> tuple[Path, Path, LintModuleOutputUpdate]: filename = tmp_path / f"{base}.py" expected_output_file = tmp_path / f"{base}.txt" lmou = LintModuleOutputUpdate( test_file=FunctionalTestFile(str(tmp_path), str(filename)) ) return filename, expected_output_file, lmou
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 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_not_py38(tmp_path: Path) -> None: with pytest.raises(RuntimeError, match="new AST parser"): LintModuleOutputUpdate(test_file=FunctionalTestFile( str(tmp_path), str(tmp_path / "filename.py")))