Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run test on pypy #257

Merged
merged 5 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we are missing a __init__.py in the cybin folder, modern version of Python (not Python2) will treat this folder as a namespace module, so it's not None.

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
7 changes: 4 additions & 3 deletions tests/test_protocol_cybinary.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@
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


if PYPY:
aisk marked this conversation as resolved.
Show resolved Hide resolved
pytest.skip("cython not enabled in pypy.", allow_module_level=True)


class TItem(TPayload):
thrift_spec = {
1: (TType.I32, "id", False),
Expand Down
Loading