From cacc88eb551b41704751faf162c60e446f36dd7f Mon Sep 17 00:00:00 2001 From: Stefan VanBuren Date: Wed, 28 Jan 2026 15:18:43 -0500 Subject: [PATCH 1/2] Bump pytest version to 9 Ref: https://docs.pytest.org/en/stable/changelog.html#pytest-9-0-0-2025-11-05 --- pyproject.toml | 99 +++++++++++++++++++++++---------------------- test/test_format.py | 54 +++++++++++++------------ uv.lock | 2 +- 3 files changed, 79 insertions(+), 76 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9e78f3a..c5f51fb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,17 +22,17 @@ classifiers = [ ] dynamic = ["version"] dependencies = [ - "protobuf>=5", - "cel-python==0.2.*", - # We need at least this version, which started publishing wheels for Python 3.14. - # Ref: https://github.com/google/re2/issues/580 - "google-re2>=1.1.20251105; python_version == '3.14'", - # We need at least this version, which started publishing wheels for Python 3.13. - # Ref: https://github.com/google/re2/issues/516 - "google-re2>=1.1.20250722; python_version == '3.13'", - # 1.1 started supporting 3.12. - "google-re2>=1.1; python_version == '3.12'", - "google-re2>=1", + "protobuf>=5", + "cel-python==0.2.*", + # We need at least this version, which started publishing wheels for Python 3.14. + # Ref: https://github.com/google/re2/issues/580 + "google-re2>=1.1.20251105; python_version == '3.14'", + # We need at least this version, which started publishing wheels for Python 3.13. + # Ref: https://github.com/google/re2/issues/516 + "google-re2>=1.1.20250722; python_version == '3.13'", + # 1.1 started supporting 3.12. + "google-re2>=1.1; python_version == '3.12'", + "google-re2>=1", ] [project.urls] @@ -42,11 +42,11 @@ Issues = "https://github.com/bufbuild/protovalidate-python/issues" [dependency-groups] dev = [ - "google-re2-stubs>=0.1.1", - "mypy>=1.17.1", - "pytest>=8.4.1", - "ruff>=0.12.0", - "types-protobuf>=5.29.1.20250315", + "google-re2-stubs>=0.1.1", + "mypy>=1.17.1", + "pytest>=9.0.2", + "ruff>=0.12.0", + "types-protobuf>=5.29.1.20250315", ] [tool.uv] @@ -59,40 +59,40 @@ raw-options = { fallback_version = "0.0.0" } [tool.ruff] line-length = 120 lint.select = [ - "A", - "ARG", - "B", - "C", - "DTZ", - "E", - "EM", - "F", - "FBT", - "I", - "ICN", - "N", - "PLC", - "PLE", - "PLR", - "PLW", - "Q", - "RUF", - "S", - "T", - "TID", - "UP", - "W", - "YTT", + "A", + "ARG", + "B", + "C", + "DTZ", + "E", + "EM", + "F", + "FBT", + "I", + "ICN", + "N", + "PLC", + "PLE", + "PLR", + "PLW", + "Q", + "RUF", + "S", + "T", + "TID", + "UP", + "W", + "YTT", ] lint.ignore = [ - # Ignore complexity - "C901", - "PLR0911", - "PLR0912", - "PLR0913", - "PLR0915", - # Ignore magic values - in this library, most are obvious in context. - "PLR2004", + # Ignore complexity + "C901", + "PLR0911", + "PLR0912", + "PLR0913", + "PLR0915", + # Ignore magic values - in this library, most are obvious in context. + "PLR2004", ] [tool.ruff.lint.isort] @@ -105,7 +105,8 @@ ban-relative-imports = "all" # Tests can use assertions. "test/**/*" = ["S101"] -[tool.pytest.ini_options] +[tool.pytest] +strict = true # restrict testpaths to speed up test discovery testpaths = ["test"] diff --git a/test/test_format.py b/test/test_format.py index d206ef6..29703e6 100644 --- a/test/test_format.py +++ b/test/test_format.py @@ -101,34 +101,36 @@ def get_eval_error_message(test: simple_pb2.SimpleTest) -> str | None: env = celpy.Environment(runner_class=InterpretedRunner) -@pytest.mark.parametrize("format_test", _format_tests) -def test_format_successes(format_test): +def test_format_successes(subtests): """Tests success scenarios for string.format""" - if format_test.name in skipped_tests: - pytest.skip(f"skipped test: {format_test.name}") - ast = env.compile(format_test.expr) - prog = env.program(ast, functions=extra_func.make_extra_funcs()) + for format_test in _format_tests: + with subtests.test(msg=format_test.name): + if format_test.name in skipped_tests: + pytest.skip(f"skipped test: {format_test.name}") + ast = env.compile(format_test.expr) + prog = env.program(ast, functions=extra_func.make_extra_funcs()) - bindings = build_variables(format_test.bindings) - result = prog.evaluate(bindings) - expected = get_expected_result(format_test) - assert expected is not None, f"[{format_test.name}]: expected a success result to be defined" - assert result == expected + bindings = build_variables(format_test.bindings) + result = prog.evaluate(bindings) + expected = get_expected_result(format_test) + assert expected is not None, f"[{format_test.name}]: expected a success result to be defined" + assert result == expected -@pytest.mark.parametrize("format_error_test", _format_error_tests) -def test_format_errors(format_error_test): +def test_format_errors(subtests): """Tests error scenarios for string.format""" - if format_error_test.name in skipped_error_tests: - pytest.skip(f"skipped test: {format_error_test.name}") - ast = env.compile(format_error_test.expr) - prog = env.program(ast, functions=extra_func.make_extra_funcs()) - - bindings = build_variables(format_error_test.bindings) - try: - prog.evaluate(bindings) - pytest.fail(f"[{format_error_test.name}]: expected an error to be raised during evaluation") - except celpy.CELEvalError as e: - msg = get_eval_error_message(format_error_test) - assert msg is not None, f"[{format_error_test.name}]: expected an eval error to be defined" - assert str(e) == msg + for format_error_test in _format_error_tests: + with subtests.test(msg=format_error_test.name): + if format_error_test.name in skipped_error_tests: + pytest.skip(f"skipped test: {format_error_test.name}") + ast = env.compile(format_error_test.expr) + prog = env.program(ast, functions=extra_func.make_extra_funcs()) + + bindings = build_variables(format_error_test.bindings) + try: + prog.evaluate(bindings) + pytest.fail(f"[{format_error_test.name}]: expected an error to be raised during evaluation") + except celpy.CELEvalError as e: + msg = get_eval_error_message(format_error_test) + assert msg is not None, f"[{format_error_test.name}]: expected an eval error to be defined" + assert str(e) == msg diff --git a/uv.lock b/uv.lock index 95d6fe6..984f04c 100644 --- a/uv.lock +++ b/uv.lock @@ -698,7 +698,7 @@ requires-dist = [ dev = [ { name = "google-re2-stubs", specifier = ">=0.1.1" }, { name = "mypy", specifier = ">=1.17.1" }, - { name = "pytest", specifier = ">=8.4.1" }, + { name = "pytest", specifier = ">=9.0.2" }, { name = "ruff", specifier = ">=0.12.0" }, { name = "types-protobuf", specifier = ">=5.29.1.20250315" }, ] From f6fe322f537eadc969fc12af4914d008f5a059c7 Mon Sep 17 00:00:00 2001 From: Stefan VanBuren Date: Wed, 28 Jan 2026 16:48:58 -0500 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Adrien --- test/test_format.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_format.py b/test/test_format.py index 29703e6..5201384 100644 --- a/test/test_format.py +++ b/test/test_format.py @@ -101,7 +101,7 @@ def get_eval_error_message(test: simple_pb2.SimpleTest) -> str | None: env = celpy.Environment(runner_class=InterpretedRunner) -def test_format_successes(subtests): +def test_format_successes(subtests: pytest.Subtests): """Tests success scenarios for string.format""" for format_test in _format_tests: with subtests.test(msg=format_test.name): @@ -117,7 +117,7 @@ def test_format_successes(subtests): assert result == expected -def test_format_errors(subtests): +def test_format_errors(subtests: pytest.Subtests): """Tests error scenarios for string.format""" for format_error_test in _format_error_tests: with subtests.test(msg=format_error_test.name):