Skip to content

Commit ffb41a3

Browse files
Fix conformance test ci for python 3.12
1 parent 11c90b2 commit ffb41a3

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@ test: generate install $(TESTDATA_FILE) ## Run unit tests
6666

6767
.PHONY: conformance
6868
conformance: $(BIN)/protovalidate-conformance generate install ## Run conformance tests
69-
rm test/__init__.py # the init is required for pytest to work, but confuses python when running a standard script
7069
$(BIN)/protovalidate-conformance $(CONFORMANCE_ARGS) uv run test/conformance/runner.py
71-
touch test/__init__.py
72-
$(ADD_LICENSE_HEADER)
7370

7471
.PHONY: lint
7572
lint: install $(BIN)/buf ## Lint code

test/conformance/runner.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,21 @@
1414

1515
import sys
1616
import typing
17+
from pathlib import Path
1718

1819
import celpy
1920
from google.protobuf import any_pb2, descriptor, descriptor_pool, message_factory
2021

2122
import protovalidate
22-
from test.gen.buf.validate.conformance.cases import (
23+
24+
# this is run as a standard python script, not via pytest, so we need to append the correct path to the sys.path
25+
# to make below import work. We can't use test.gen.buf.validate.conformance.cases because that would require an
26+
# __init__.py in every directory level.
27+
test_dir_path = Path(__file__).parent.parent.absolute().as_posix()
28+
if test_dir_path not in sys.path:
29+
sys.path.append(test_dir_path)
30+
31+
from gen.buf.validate.conformance.cases import (
2332
bool_pb2, # noqa: F401
2433
bytes_pb2, # noqa: F401
2534
enums_pb2, # noqa: F401
@@ -50,8 +59,8 @@
5059
wkt_timestamp_pb2, # noqa: F401
5160
wkt_wrappers_pb2, # noqa: F401
5261
)
53-
from test.gen.buf.validate.conformance.cases.custom_rules import custom_rules_pb2 # noqa: F401
54-
from test.gen.buf.validate.conformance.harness import harness_pb2
62+
from gen.buf.validate.conformance.cases.custom_rules import custom_rules_pb2 # noqa: F401
63+
from gen.buf.validate.conformance.harness import harness_pb2
5564

5665

5766
def run_test_case(tc: typing.Any, result: harness_pb2.TestResult | None = None) -> harness_pb2.TestResult:

0 commit comments

Comments
 (0)