Skip to content

Commit 2b219aa

Browse files
Scope generated test files to gen package rather than test.gen
1 parent 20deb20 commit 2b219aa

26 files changed

+65
-45
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ generate-protobuf-tests: $(BIN)/buf ## Regenerate protobuf gencode used in unit
4545

4646
# generate cel-spec into test/gen/cel/expr
4747
$(BIN)/buf generate buf.build/google/cel-spec:$(CEL_SPEC_VERSION) --exclude-path cel/expr/conformance/proto2 --exclude-path cel/expr/conformance/proto3
48-
# we need to update the `from cel.expr` imports in those generated files to `from test.gen.cel.expr`
49-
LC_ALL=C find test/gen/cel -type f -exec sed -i.bak 's/from cel.expr/from test.gen.cel.expr/g' {} + && find test/gen/cel -name '*.bak' -delete
48+
# we need to update the `from cel.expr` imports in those generated files to `from gen.cel.expr`
49+
LC_ALL=C find test/gen/cel -type f -exec sed -i.bak 's/from cel.expr/from gen.cel.expr/g' {} + && find test/gen/cel -name '*.bak' -delete
5050
# also update buf.validate.conformance imports
51-
LC_ALL=C find test/gen/buf/validate/conformance -type f -exec sed -i.bak 's/from buf.validate.conformance/from test.gen.buf.validate.conformance/g' {} + && find test/gen/buf/validate/conformance -name '*.bak' -delete
51+
LC_ALL=C find test/gen/buf/validate/conformance -type f -exec sed -i.bak 's/from buf.validate.conformance/from gen.buf.validate.conformance/g' {} + && find test/gen/buf/validate/conformance -name '*.bak' -delete
5252

5353
# generate proto/tests/example/v1/validations.proto into test/gen/tests/example/v1
5454
$(BIN)/buf generate

test/conftest.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2023-2025 Buf Technologies, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import sys
16+
from pathlib import Path
17+
18+
test_dir_path = Path(__file__).parent.absolute().as_posix()
19+
if test_dir_path not in sys.path:
20+
sys.path.append(test_dir_path)

test/gen/buf/validate/conformance/cases/enums_pb2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
_sym_db = _symbol_database.Default()
2727

2828

29-
from test.gen.buf.validate.conformance.cases.other_package import embed_pb2 as buf_dot_validate_dot_conformance_dot_cases_dot_other__package_dot_embed__pb2
30-
from test.gen.buf.validate.conformance.cases.yet_another_package import embed2_pb2 as buf_dot_validate_dot_conformance_dot_cases_dot_yet__another__package_dot_embed2__pb2
29+
from gen.buf.validate.conformance.cases.other_package import embed_pb2 as buf_dot_validate_dot_conformance_dot_cases_dot_other__package_dot_embed__pb2
30+
from gen.buf.validate.conformance.cases.yet_another_package import embed2_pb2 as buf_dot_validate_dot_conformance_dot_cases_dot_yet__another__package_dot_embed2__pb2
3131
from buf.validate import validate_pb2 as buf_dot_validate_dot_validate__pb2
3232

3333

test/gen/buf/validate/conformance/cases/enums_pb2.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from test.gen.buf.validate.conformance.cases.other_package import embed_pb2 as _embed_pb2
16-
from test.gen.buf.validate.conformance.cases.yet_another_package import embed2_pb2 as _embed2_pb2
15+
from gen.buf.validate.conformance.cases.other_package import embed_pb2 as _embed_pb2
16+
from gen.buf.validate.conformance.cases.yet_another_package import embed2_pb2 as _embed2_pb2
1717
from buf.validate import validate_pb2 as _validate_pb2
1818
from google.protobuf.internal import containers as _containers
1919
from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper

test/gen/buf/validate/conformance/cases/messages_pb2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
_sym_db = _symbol_database.Default()
2727

2828

29-
from test.gen.buf.validate.conformance.cases.other_package import embed_pb2 as buf_dot_validate_dot_conformance_dot_cases_dot_other__package_dot_embed__pb2
29+
from gen.buf.validate.conformance.cases.other_package import embed_pb2 as buf_dot_validate_dot_conformance_dot_cases_dot_other__package_dot_embed__pb2
3030
from buf.validate import validate_pb2 as buf_dot_validate_dot_validate__pb2
3131

3232

test/gen/buf/validate/conformance/cases/messages_pb2.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from test.gen.buf.validate.conformance.cases.other_package import embed_pb2 as _embed_pb2
15+
from gen.buf.validate.conformance.cases.other_package import embed_pb2 as _embed_pb2
1616
from buf.validate import validate_pb2 as _validate_pb2
1717
from google.protobuf import descriptor as _descriptor
1818
from google.protobuf import message as _message

test/gen/buf/validate/conformance/cases/predefined_rules_proto3_pb2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
_sym_db = _symbol_database.Default()
2727

2828

29-
from test.gen.buf.validate.conformance.cases import predefined_rules_proto2_pb2 as buf_dot_validate_dot_conformance_dot_cases_dot_predefined__rules__proto2__pb2
30-
from test.gen.buf.validate.conformance.cases import predefined_rules_proto_editions_pb2 as buf_dot_validate_dot_conformance_dot_cases_dot_predefined__rules__proto__editions__pb2
29+
from gen.buf.validate.conformance.cases import predefined_rules_proto2_pb2 as buf_dot_validate_dot_conformance_dot_cases_dot_predefined__rules__proto2__pb2
30+
from gen.buf.validate.conformance.cases import predefined_rules_proto_editions_pb2 as buf_dot_validate_dot_conformance_dot_cases_dot_predefined__rules__proto__editions__pb2
3131
from buf.validate import validate_pb2 as buf_dot_validate_dot_validate__pb2
3232
from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2
3333
from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2

test/gen/buf/validate/conformance/cases/predefined_rules_proto3_pb2.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from test.gen.buf.validate.conformance.cases import predefined_rules_proto2_pb2 as _predefined_rules_proto2_pb2
16-
from test.gen.buf.validate.conformance.cases import predefined_rules_proto_editions_pb2 as _predefined_rules_proto_editions_pb2
15+
from gen.buf.validate.conformance.cases import predefined_rules_proto2_pb2 as _predefined_rules_proto2_pb2
16+
from gen.buf.validate.conformance.cases import predefined_rules_proto_editions_pb2 as _predefined_rules_proto_editions_pb2
1717
from buf.validate import validate_pb2 as _validate_pb2
1818
from google.protobuf import duration_pb2 as _duration_pb2
1919
from google.protobuf import timestamp_pb2 as _timestamp_pb2

test/gen/buf/validate/conformance/cases/repeated_pb2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
_sym_db = _symbol_database.Default()
2727

2828

29-
from test.gen.buf.validate.conformance.cases.other_package import embed_pb2 as buf_dot_validate_dot_conformance_dot_cases_dot_other__package_dot_embed__pb2
29+
from gen.buf.validate.conformance.cases.other_package import embed_pb2 as buf_dot_validate_dot_conformance_dot_cases_dot_other__package_dot_embed__pb2
3030
from buf.validate import validate_pb2 as buf_dot_validate_dot_validate__pb2
3131
from google.protobuf import any_pb2 as google_dot_protobuf_dot_any__pb2
3232
from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2

test/gen/buf/validate/conformance/cases/repeated_pb2.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from test.gen.buf.validate.conformance.cases.other_package import embed_pb2 as _embed_pb2
15+
from gen.buf.validate.conformance.cases.other_package import embed_pb2 as _embed_pb2
1616
from buf.validate import validate_pb2 as _validate_pb2
1717
from google.protobuf import any_pb2 as _any_pb2
1818
from google.protobuf import duration_pb2 as _duration_pb2

0 commit comments

Comments
 (0)