Skip to content

Commit

Permalink
chore: workarounds for python 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Aug 3, 2023
1 parent 019957a commit 8c743cd
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 23 deletions.
11 changes: 6 additions & 5 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ linux_arm64_task:
only_if: $CIRRUS_CHANGE_TITLE !=~ 'ci\(gha\).*'
env:
# PACT_FFI_PATH: .tox/test/lib/python$VERSION/site-packages/pact/bin
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: python
matrix:
- VERSION: 3.6
- VERSION: 3.7
Expand All @@ -42,11 +43,11 @@ macos_arm64_task:
PATH: ${HOME}/.pyenv/shims:${PATH}
# PACT_FFI_PATH: .tox/test/lib/python$VERSION/site-packages/pact/bin
matrix:
# - VERSION: 3.6
# - VERSION: 3.7
# - VERSION: 3.8
# - VERSION: 3.9
# - VERSION: 3.10
- VERSION: 3.6
- VERSION: 3.7
- VERSION: 3.8
- VERSION: 3.9
- VERSION: 3.10
- VERSION: 3.11
install_script:
- brew update
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ jobs:
macos-latest
]

# # These versions are no longer supported by Python team, and may
# # eventually be dropped from GitHub Actions.
# include:
# - python-version: '3.6'
# os: ubuntu-20.04
# These versions are no longer supported by Python team, and may
# eventually be dropped from GitHub Actions.
include:
- python-version: '3.6'
os: ubuntu-20.04

steps:
- name: Check out code
Expand Down
6 changes: 4 additions & 2 deletions examples/area_calculator/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
grpcio==1.50.0
grpcio-tools==1.50.0
grpcio==1.48.2; python_version < '3.7'
grpcio==1.56.2; python_version >= '3.7'
grpcio-tools==1.48.2; python_version < '3.7'
grpcio-tools==1.56.2; python_version >= '3.7
3 changes: 2 additions & 1 deletion examples/common/sharedfixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def publish_existing_pact(broker):
'--broker-base-url', envs["PACT_BROKER_BASE_URL"],
'--broker-username', envs["PACT_BROKER_USERNAME"],
'--broker-password', envs["PACT_BROKER_PASSWORD"]
], capture_output=True, text=True)
],
)
print(result.stdout)
print(result.stderr)

Expand Down
6 changes: 4 additions & 2 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ httpx==0.22.0; python_version < '3.7'
httpx==0.23.3; python_version >= '3.7'
cffi>=1.14.6
pytest-httpserver==1.0.1
grpcio==1.56.2
grpcio-tools==1.56.2
grpcio==1.48.2; python_version < '3.7'
grpcio==1.56.2; python_version >= '3.7'
grpcio-tools==1.48.2; python_version < '3.7'
grpcio-tools==1.56.2; python_version >= '3.7'
23 changes: 15 additions & 8 deletions tests/ffi/test_ffi_grpc_consumer.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
from pact.ffi.native_mock_server import MockServer, MockServerStatus
import json
import os
from pact.ffi.native_mock_server import MockServer, MockServerStatus
from sys import path
import pytest
from sys import path, version_info
path.insert(0, './examples/area_calculator')
from area_calculator_client import get_rectangle_area # noqa: E402

# from examples.area_calculator.area_calculator_client import get_rectangle_area

m = MockServer()
PACT_FILE_DIR = './examples/pacts'
if version_info < (3, 7):
try:
from area_calculator_client import get_rectangle_area # noqa: E402
except ImportError:
print("Skipping import for Python 3.6 due to protobuf error")
else:
from area_calculator_client import get_rectangle_area # noqa: E402

@pytest.mark.skipif(
version_info < (3, 7),
reason="https://stackoverflow.com/questions/71759248/importerror-cannot-import-name-builder-from-google-protobuf-internal")
def test_ffi_grpc_consumer():
# Setup pact for testing
m = MockServer()
PACT_FILE_DIR = './examples/pacts'
pact = m.new_pact('grpc-consumer-python', 'area-calculator-provider')
message_pact = m.new_sync_message_interaction(pact, 'A gRPC calculateMulti request')
m.with_specification(pact, 5)
Expand Down
4 changes: 4 additions & 0 deletions tests/ffi/test_v3_verifier.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from sys import version_info
from time import sleep
import pytest
from pact import VerifierV3
Expand Down Expand Up @@ -175,6 +176,9 @@ def test_local_http_v3_pact(httpserver):
)
assert VerifyStatus(result.return_code) == VerifyStatus.SUCCESS

@pytest.mark.skipif(
version_info < (3, 7),
reason="https://stackoverflow.com/questions/71759248/importerror-cannot-import-name-builder-from-google-protobuf-internal")
def test_grpc_local_pact():

grpc_server_process = subprocess.Popen(['python', 'area_calculator_server.py'],
Expand Down

0 comments on commit 8c743cd

Please sign in to comment.