Skip to content

Commit

Permalink
Merge pull request #1 from ZeroIntensity/tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroIntensity authored Apr 23, 2024
2 parents 716982a + 136cca8 commit 5b39ef7
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 7 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Tests

on:
push:
branches:
- master
pull_request:
branches:
- master

concurrency:
group: test-${{ github.head_ref }}
cancel-in-progress: true

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"
PYTHONIOENCODING: "utf8"

jobs:
run:
name: Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-12]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install Ward
run: pip install --upgrade --pre ward

- name: Install project
run: pip install .

- name: Run tests
run: ward
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from setuptools import Extension, setup

HEADER_FILES: list[str] = ["./include/awaitable.h"]

if __name__ == "__main__":
setup(
ext_modules=[
Expand All @@ -12,5 +10,5 @@
define_macros=[("PYAWAITABLE_IS_COMPILING", None)],
)
],
data_files=[("include", HEADER_FILES)],
data_files=[("include", ["./include/awaitable.h"])],
)
7 changes: 3 additions & 4 deletions src/awaitable.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
// This code follows PEP 7 and CPython ABI conventions
#include <Python.h>
#include "pyerrors.h"
#include <awaitable.h>
#include <stdarg.h>
#include <stdbool.h>

#include <awaitable.h>

#ifndef _PyObject_Vectorcall
#define PyObject_CallNoArgs(o) PyObject_CallObject( \
Expand Down Expand Up @@ -471,7 +470,7 @@ awaitable_throw(PyObject *self, PyObject *args)
assert(NULL);
}

#if PY_MINOR_VERSION > 8
#if PY_MINOR_VERSION > 9
static PySendResult
awaitable_am_send(PyObject *self, PyObject *arg, PyObject **presult) {
PyObject *send_res = awaitable_send_with_arg(self, arg);
Expand Down Expand Up @@ -505,7 +504,7 @@ static PyMethodDef awaitable_methods[] = {
};

static PyAsyncMethods async_methods = {
#if PY_MINOR_VERSION == 8
#if PY_MINOR_VERSION < 10
.am_await = awaitable_next
#else
.am_await = awaitable_next,
Expand Down
12 changes: 12 additions & 0 deletions tests/test_awaitable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from ward import test
import pyawaitable
import ctypes as ct
from ctypes import pythonapi

get_pointer = pythonapi.PyCapsule_GetPointer
get_pointer.argtypes = (ct.py_object, ct.c_void_p)
get_pointer.restype = ct.c_void_p

@test("awaitable creation")
async def _():
ptr = get_pointer(pyawaitable._api, None)

0 comments on commit 5b39ef7

Please sign in to comment.