Skip to content
New issue

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

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

Already on GitHub? # to your account

Run the test on Windows on GHA #259

Merged
merged 7 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -12,11 +12,12 @@ on:
jobs:
build:

runs-on: ubuntu-20.04
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.9", "pypy3.10"]
os: ["ubuntu-20.04", "windows-latest"]

steps:
- uses: actions/checkout@v3
Expand All @@ -28,7 +29,6 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest pytest-asyncio cython
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand Down
7 changes: 7 additions & 0 deletions tests/test_aio.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import os
import sys
import asyncio
# import uvloop
import threading
Expand All @@ -26,6 +27,12 @@
from thriftpy2.transport import TTransportException
from thriftpy2.thrift import TApplicationException


if sys.platform == "win32":
pytest.skip("Unix domain socket is not supported on Windows",
allow_module_level=True)


addressbook = thriftpy2.load(os.path.join(os.path.dirname(__file__),
"addressbook.thrift"))

Expand Down
6 changes: 6 additions & 0 deletions tests/test_all_protocols_binary_field.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import absolute_import

import sys
import time
import traceback
from multiprocessing import Process
Expand All @@ -24,6 +25,11 @@
make_client as make_rpc_client
from thriftpy2.transport import TBufferedTransportFactory, TCyMemoryBuffer


if sys.platform == "win32":
pytest.skip("requires fork", allow_module_level=True)


protocols = [TApacheJSONProtocolFactory,
TJSONProtocolFactory,
TBinaryProtocolFactory,
Expand Down
2 changes: 2 additions & 0 deletions tests/test_apache_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import absolute_import

import json
import sys
import time
from multiprocessing import Process

Expand Down Expand Up @@ -126,6 +127,7 @@ def test(t):
json.loads(final_data.decode('utf8'))[4]['0']


@pytest.mark.skipif(sys.platform == "win32", reason="this test requires fork")
@pytest.mark.parametrize('server_func', [(make_rpc_server, make_rpc_client),
(make_http_server, make_http_client)])
def test_client(server_func):
Expand Down
5 changes: 4 additions & 1 deletion tests/test_buffered_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

import logging
import multiprocessing
import sys
import time

from os import path

import pytest
from unittest import TestCase

import thriftpy2
Expand Down Expand Up @@ -43,6 +45,7 @@ def get(self, name):
return self.registry[name]


@pytest.mark.skipif(sys.platform == "win32", reason="requires fork")
class BufferedTransportTestCase(TestCase):
TRANSPORT_FACTORY = TBufferedTransportFactory()
PROTOCOL_FACTORY = TBinaryProtocolFactory()
Expand Down
7 changes: 4 additions & 3 deletions tests/test_cytransport.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import pytest

from thriftpy2._compat import PYPY
from thriftpy2._compat import CYTHON

pytestmark = pytest.mark.skipif(PYPY, reason="cython not enabled in pypy.")

if not PYPY:
if CYTHON:
from thriftpy2.transport.framed import TCyFramedTransport
from thriftpy2.transport.buffered import TCyBufferedTransport
from thriftpy2.transport import TMemoryBuffer, TTransportException
else:
pytest.skip("cython not enabled.", allow_module_level=True)


def test_transport_mismatch():
Expand Down
10 changes: 9 additions & 1 deletion tests/test_framed_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@

import logging
import socket
import sys
import threading
import time

from os import path
from unittest import TestCase

import pytest
from tornado import ioloop

import thriftpy2
from thriftpy2._compat import CYTHON
from thriftpy2.tornado import make_server
from thriftpy2.rpc import make_client
from thriftpy2.transport.framed import TFramedTransportFactory
Expand All @@ -23,7 +26,12 @@
except ImportError:
asyncio = None

from thriftpy2._compat import CYTHON

if sys.platform == "win32":
pytest.skip("add_socket is not implemented on Windiws",
allow_module_level=True)


logging.basicConfig(level=logging.INFO)

addressbook = thriftpy2.load(path.join(path.dirname(__file__),
Expand Down
5 changes: 5 additions & 0 deletions tests/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import multiprocessing
import socket
import sys
import time
import uuid

Expand All @@ -21,6 +22,10 @@
"addressbook.thrift"))


if sys.platform == "win32":
pytest.skip("requires fork", allow_module_level=True)


class Dispatcher():
def __init__(self):
self.ab = addressbook.AddressBook()
Expand Down
7 changes: 6 additions & 1 deletion tests/test_multiplexed.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

from __future__ import absolute_import

import os
import multiprocessing
import os
import sys
import time

import pytest
Expand All @@ -19,6 +20,10 @@
from thriftpy2.transport import TBufferedTransportFactory, TServerSocket


if sys.platform == "win32":
pytest.skip("requires fork", allow_module_level=True)


mux = thriftpy2.load(os.path.join(os.path.dirname(__file__),
"multiplexed.thrift"))
sock_path = "/tmp/thriftpy_test.sock"
Expand Down
10 changes: 9 additions & 1 deletion tests/test_oneway.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import sys
import time

import pytest

import multiprocessing
import thriftpy2
import time
from thriftpy2.rpc import make_client, make_server


if sys.platform == "win32":
pytest.skip("requires fork", allow_module_level=True)


class Dispatcher(object):
def Test(self, req):
print("Get req msg: %s" % req)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_protocol_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +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")
@pytest.mark.skipif(not _compat.CYTHON, reason="cybin required")
def test_string_binary_equivalency():
from thriftpy2.protocol.binary import TBinaryProtocolFactory
from thriftpy2.protocol.cybin import TCyBinaryProtocolFactory
Expand Down
6 changes: 3 additions & 3 deletions tests/test_protocol_cybinary.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

import pytest

from thriftpy2._compat import PYPY
from thriftpy2._compat import CYTHON
from thriftpy2.thrift import TDecodeException, TPayload, TType
from thriftpy2.transport import TServerSocket, TSocket
from thriftpy2.utils import hexlify
if not PYPY:
if CYTHON:
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)
pytest.skip("cython not enabled.", allow_module_level=True)


class TItem(TPayload):
Expand Down
9 changes: 7 additions & 2 deletions tests/test_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

from __future__ import absolute_import

import os
import multiprocessing
import os
import socket
import time
import ssl
import sys
import time

import pytest

Expand All @@ -19,6 +20,10 @@
from thriftpy2.thrift import TApplicationException # noqa


if sys.platform == "win32":
pytest.skip("requires unix domain socket", allow_module_level=True)


addressbook = thriftpy2.load(os.path.join(os.path.dirname(__file__),
"addressbook.thrift"))
unix_sock = "/tmp/thriftpy_test.sock"
Expand Down
2 changes: 2 additions & 0 deletions tests/test_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ def test_inet6_socket():
@pytest.mark.skipif(
sys.platform == 'darwin' and os.getuid() != 0,
reason='os.mknod() requires super-user privileges on darwin')
@pytest.mark.skipif(sys.platform == "win32",
reason="os.mknod is missing on Windows")
def test_unix_domain_socket():
sock_file = "/tmp/thriftpy_test.sock"

Expand Down
5 changes: 5 additions & 0 deletions tests/test_tornado.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@
import logging
import socket

import pytest
from tornado import gen, testing

import thriftpy2
from thriftpy2.tornado import make_client
from thriftpy2.tornado import make_server
from thriftpy2.transport import TTransportException

if sys.platform == "win32":
pytest.skip("add_socket is not implemented on Windiws",
allow_module_level=True)

logging.basicConfig(level=logging.INFO)

addressbook = thriftpy2.load(path.join(path.dirname(__file__),
Expand Down
6 changes: 6 additions & 0 deletions tests/test_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import pickle
import random
import socket
import sys
import tempfile
import time

Expand Down Expand Up @@ -57,6 +58,11 @@
else:
cleanup_on_sigterm()


if sys.platform == "win32":
pytest.skip("requires fork", allow_module_level=True)


addressbook = thriftpy2.load(os.path.join(os.path.dirname(__file__),
"addressbook.thrift"))
_, db_file = tempfile.mkstemp()
Expand Down
Loading