Skip to content

Commit

Permalink
Run test on pypy (#257)
Browse files Browse the repository at this point in the history
* Run test on pypy

* Update checkout python version

* Fix test in pypy

* Fix test

* Update tests/test_protocol_cybinary.py
  • Loading branch information
aisk authored Apr 5, 2024
1 parent 7419e30 commit 62979f4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.9", "pypy3.10"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
9 changes: 3 additions & 6 deletions tests/test_all_protocols_binary_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
import pytest
import six

from thriftpy2 import _compat
from thriftpy2.thrift import TType, TPayloadMeta
try:
from thriftpy2.protocol import cybin
except ImportError:
cybin = None
import thriftpy2
from thriftpy2.http import (
make_server as make_http_server,
Expand Down Expand Up @@ -263,12 +260,12 @@ def run_server():
time.sleep(0.2)


@pytest.mark.skipif(cybin is None, reason="Must be run in cpython")
@pytest.mark.skipif(_compat.PYPY, reason="Must be run in cpython")
def test_complex_map():
"""
Test from #156
"""
proto = cybin
from thriftpy2.protocol import cybin as proto
b1 = TCyMemoryBuffer()
proto.write_val(b1, TType.MAP, {"hello": "1"},
spec=(TType.STRING, TType.STRING))
Expand Down
2 changes: 2 additions & 0 deletions tests/test_protocol_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import pytest

from thriftpy2 import _compat
from thriftpy2 import load
from thriftpy2.protocol import binary as proto
from thriftpy2.thrift import TPayload, TType
Expand Down Expand Up @@ -172,6 +173,7 @@ def test_write_huge_struct():
proto.TBinaryProtocol(b).write_struct(item)


@pytest.mark.skipif(_compat.PYPY, reason="cybin can't be used in pypy")
def test_string_binary_equivalency():
from thriftpy2.protocol.binary import TBinaryProtocolFactory
from thriftpy2.protocol.cybin import TCyBinaryProtocolFactory
Expand Down
5 changes: 2 additions & 3 deletions tests/test_protocol_cybinary.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
from thriftpy2.thrift import TDecodeException, TPayload, TType
from thriftpy2.transport import TServerSocket, TSocket
from thriftpy2.utils import hexlify

pytestmark = pytest.mark.skipif(PYPY,
reason="cython not enabled in pypy.")
if not PYPY:
from thriftpy2.protocol import cybin as proto
from thriftpy2.transport.buffered import TCyBufferedTransport
from thriftpy2.transport.memory import TCyMemoryBuffer
else:
pytest.skip("cython not enabled in pypy.", allow_module_level=True)


class TItem(TPayload):
Expand Down

0 comments on commit 62979f4

Please sign in to comment.