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

Upstream some Hypothesis support into Trio #144

Merged
merged 4 commits into from
Jul 30, 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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['3.7', '3.8', '3.9', '3.10', '3.11']
python: ['3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -35,7 +35,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['pypy-3.7', '3.7', 'pypy-3.8', '3.8', 'pypy-3.9', '3.9', '3.10', '3.11']
python: ['pypy-3.8', '3.8', 'pypy-3.9', '3.9', 'pypy-3.10', '3.10', '3.11', '3.12']
check_formatting: ['0']
check_docs: ['0']
extra_name: ['']
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['3.7', '3.8', '3.9', '3.10', '3.11']
python: ['3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
6 changes: 5 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# https://docs.readthedocs.io/en/latest/config-file/index.html
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.9"

formats:
- htmlzip
- epub

python:
version: 3.7
install:
- requirements: docs-requirements.txt

Expand Down
2 changes: 1 addition & 1 deletion docs-requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ towncrier != 19.9.0,!= 21.3.0
# pytest-trio's own dependencies
trio >= 0.22.0
outcome >= 1.1.0
pytest >= 7.2.0
pytest >= 8.2.0
13 changes: 4 additions & 9 deletions docs-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# This file is autogenerated by pip-compile with python 3.8
# To update, run:
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile docs-requirements.in
#
Expand All @@ -12,7 +12,6 @@ attrs==22.1.0
# via
# -r docs-requirements.in
# outcome
# pytest
# trio
babel==2.10.3
# via sphinx
Expand Down Expand Up @@ -40,8 +39,6 @@ idna==3.4
# trio
imagesize==1.4.1
# via sphinx
importlib-metadata==5.0.0
# via sphinx
incremental==22.10.0
# via towncrier
iniconfig==1.1.1
Expand All @@ -60,13 +57,13 @@ packaging==21.3
# via
# pytest
# sphinx
pluggy==1.0.0
pluggy==1.5.0
# via pytest
pygments==2.13.0
# via sphinx
pyparsing==3.0.9
# via packaging
pytest==7.2.0
pytest==8.2.2
# via -r docs-requirements.in
pytz==2022.5
# via babel
Expand Down Expand Up @@ -109,8 +106,6 @@ trio==0.22.0
# via -r docs-requirements.in
urllib3==1.26.12
# via requests
zipp==3.10.0
# via importlib-metadata

# The following packages are considered to be unsafe in a requirements file:
# setuptools
3 changes: 3 additions & 0 deletions newsfragments/143.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Move some Hypothesis support into Trio itself, via the new plugins system.
As a result, ``pytest-trio`` will not import Hypothesis, while still
integrating seamlessly if _you_ import it.
2 changes: 1 addition & 1 deletion newsfragments/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ message and PR description, which are a description of the change as
relevant to people working on the code itself.)

Each file should be named like ``<ISSUE>.<TYPE>.rst``, where
``<ISSUE>`` is an issue numbers, and ``<TYPE>`` is one of:
``<ISSUE>`` is an issue number, and ``<TYPE>`` is one of:

* ``feature``
* ``bugfix``
Expand Down
15 changes: 1 addition & 14 deletions pytest_trio/plugin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""pytest-trio implementation."""

import sys
from functools import wraps, partial
from collections.abc import Coroutine, Generator
Expand All @@ -19,20 +20,6 @@
# Basic setup
################################################################

try:
from hypothesis import register_random
except ImportError: # pragma: no cover
pass
else:
# On recent versions of Hypothesis, make the Trio scheduler deterministic
# even though it uses a module-scoped Random instance. This works
# regardless of whether or not the random_module strategy is used.
register_random(trio._core._run._r)
# We also have to enable determinism, which is disabled by default
# due to a small performance impact - but fine to enable in testing.
# See https://github.com/python-trio/trio/pull/890/ for details.
trio._core._run._ALLOW_DETERMINISTIC_SCHEDULING = True


def pytest_addoption(parser):
parser.addini(
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
packages=find_packages(),
entry_points={"pytest11": ["trio = pytest_trio.plugin"]},
install_requires=[
"trio >= 0.22.0", # for ExceptionGroup support
"trio >= 0.25.1", # for upstream Hypothesis integration
"outcome >= 1.1.0",
"pytest >= 7.2.0", # for ExceptionGroup support
],
Expand All @@ -34,11 +34,11 @@
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: System :: Networking",
Expand Down
3 changes: 3 additions & 0 deletions test-requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pytest>=8.2.2
pytest-cov>=5.0.0
hypothesis>=6.108.0
37 changes: 34 additions & 3 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
pytest==7.2.0
pytest-cov==4.0.0
hypothesis==6.56.4
#
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile test-requirements.in
#
attrs==23.2.0
# via hypothesis
coverage[toml]==7.6.0
# via pytest-cov
exceptiongroup==1.2.2
# via
# hypothesis
# pytest
hypothesis==6.108.0
# via -r test-requirements.in
iniconfig==2.0.0
# via pytest
packaging==24.1
# via pytest
pluggy==1.5.0
# via pytest
pytest==8.2.2
# via
# -r test-requirements.in
# pytest-cov
pytest-cov==5.0.0
# via -r test-requirements.in
sortedcontainers==2.4.0
# via hypothesis
tomli==2.0.1
# via
# coverage
# pytest
Loading