Skip to content

Commit

Permalink
Test on Python 3.5.1 too
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Jan 12, 2020
1 parent 1cb7993 commit 9b6566d
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 12 deletions.
7 changes: 6 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
TASK: check-pypy36
check-py36:
TASK: check-py36
check-py351:
TASK: check-py351
check-py35:
TASK: check-py35
check-py37:
Expand All @@ -36,7 +38,10 @@ jobs:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.6'
- script: sudo apt-get update && sudo apt-get install libreadline-dev libsqlite3-dev shellcheck
- script: sudo apt-get update && sudo apt-get install libreadline-dev libsqlite3-dev shellcheck \
make build-essential libssl-dev zlib1g-dev libbz2-dev \
wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
displayName: Install apt dependencies
- script: ./build.sh check-installed
displayName: Install Python
Expand Down
10 changes: 8 additions & 2 deletions hypothesis-python/src/hypothesis/extra/django/_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import string
from datetime import timedelta
from decimal import Decimal
from typing import Any, Callable, Dict, Type, TypeVar, Union
from typing import Any, Callable, Dict, TypeVar, Union

import django
import django.db.models as dm
Expand All @@ -35,6 +35,12 @@
from hypothesis.provisional import ip4_addr_strings, ip6_addr_strings, urls
from hypothesis.strategies import emails

try:
# New in Python 3.5.2; so we only use the string form in annotations
from typing import Type
except ImportError:
pass

AnyField = Union[dm.Field, df.Field]
F = TypeVar("F", bound=AnyField)

Expand Down Expand Up @@ -206,7 +212,7 @@ def _for_form_boolean(field):


def register_field_strategy(
field_type: Type[AnyField], strategy: st.SearchStrategy
field_type: "Type[AnyField]", strategy: st.SearchStrategy
) -> None:
"""Add an entry to the global field-to-strategy lookup used by
:func:`~hypothesis.extra.django.from_field`.
Expand Down
4 changes: 2 additions & 2 deletions hypothesis-python/src/hypothesis/internal/reflection.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from functools import wraps
from tokenize import detect_encoding
from types import ModuleType
from typing import TypeVar
from typing import Callable, TypeVar

from hypothesis.internal.compat import (
qualname,
Expand All @@ -34,7 +34,7 @@
)
from hypothesis.vendor.pretty import pretty

C = TypeVar("C", bound=callable)
C = TypeVar("C", bound=Callable)


def fully_qualified_name(f):
Expand Down
19 changes: 13 additions & 6 deletions hypothesis-python/src/hypothesis/strategies/_internal/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@
Sequence,
Set,
Tuple,
Type,
TypeVar,
Union,
overload,
)
from uuid import UUID

Expand Down Expand Up @@ -126,6 +124,15 @@
from hypothesis.types import RandomWithSeed
from hypothesis.utils.conventions import InferType, infer, not_set

try:
# New in Python 3.5.2; so we only use the string form in annotations
from typing import Type, overload
except ImportError:

def overload(f):
return f


K = TypeVar("K")
V = TypeVar("V")
UniqueBy = Union[Callable[[Ex], Hashable], Tuple[Callable[[Ex], Hashable], ...]]
Expand Down Expand Up @@ -622,7 +629,7 @@ def sampled_from(elements: Sequence[T]) -> SearchStrategy[T]:


@overload # noqa: F811
def sampled_from(elements: Type[enum.Enum]) -> SearchStrategy[Any]:
def sampled_from(elements: "Type[enum.Enum]") -> SearchStrategy[Any]:
# `SearchStrategy[Enum]` is unreliable due to metaclass issues.
pass # pragma: no cover

Expand Down Expand Up @@ -1240,7 +1247,7 @@ def inner(*args, **kwargs):

@cacheable
@_defer_from_type
def from_type(thing: Type[Ex]) -> SearchStrategy[Ex]:
def from_type(thing: "Type[Ex]") -> SearchStrategy[Ex]:
"""Looks up the appropriate search strategy for the given type.
``from_type`` is used internally to fill in missing arguments to
Expand Down Expand Up @@ -2085,8 +2092,8 @@ def data() -> SearchStrategy[DataObject]:


def register_type_strategy(
custom_type: Type[Ex],
strategy: Union[SearchStrategy[Ex], Callable[[Type[Ex]], SearchStrategy[Ex]]],
custom_type: "Type[Ex]",
strategy: Union[SearchStrategy[Ex], Callable[["Type[Ex]"], SearchStrategy[Ex]]],
) -> None:
"""Add an entry to the global type-to-strategy lookup.
Expand Down
12 changes: 12 additions & 0 deletions hypothesis-python/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ commands =
prettyquick: python -m pytest tests/cover/
custom: python -m pytest {posargs}

[testenv:p351]
deps =
-r../requirements/test.txt
whitelist_externals=
bash
passenv=
HOME
LC_ALL
TOXENV
commands =
bash scripts/basic-test.sh

[testenv:quality]
deps=
-r../requirements/test.txt
Expand Down
8 changes: 7 additions & 1 deletion tooling/src/hypothesistooling/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ def run_tox(task, version):


# Via https://github.com/pyenv/pyenv/tree/master/plugins/python-build/share/python-build
PY351 = "3.5.1"
PY35 = "3.5.7"
PY36 = "3.6.9"
PY37 = "3.7.4"
Expand All @@ -386,7 +387,7 @@ def install_core():


# ALIASES are the executable names for each Python version
ALIASES = {PYPY35: "pypy3", PYPY36: "pypy3"}
ALIASES = {PYPY35: "pypy3", PYPY36: "pypy3", PY351: "python3.5.1"}

for n in [PY35, PY36, PY37, PY38]:
major, minor, patch = n.split(".")
Expand All @@ -402,6 +403,11 @@ def install_core():
)


@python_tests
def check_py351():
run_tox("p351", PY351)


@python_tests
def check_py35():
run_tox("py35-full", PY35)
Expand Down

0 comments on commit 9b6566d

Please sign in to comment.