Skip to content

Commit 2ace082

Browse files
authored
Merge pull request HypothesisWorks#3419 from ajcerejeira/ajcerejeira/django-username-field
2 parents d53b129 + 5c5acbc commit 2ace082

File tree

16 files changed

+53
-25
lines changed

16 files changed

+53
-25
lines changed

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ jobs:
5656
- check-django40
5757
- check-django32
5858
- check-django22
59+
- check-pandas14
5960
- check-pandas13
6061
- check-pandas12
6162
- check-pandas11
6263
- check-pandas10
63-
- check-pandas25
6464
fail-fast: false
6565
steps:
6666
- uses: actions/checkout@v2

AUTHORS.rst

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ their individual contributions.
1212
* `Adam Johnson <https://github.com/adamchainz>`_
1313
* `Adam Sven Johnson <https://www.github.com/pkqk>`_
1414
* `Afrida Tabassum <https://github.com/oxfordhalfblood>`_ (afrida@gmail.com)
15+
* `Afonso Silva <https://github.com/ajcerejeira>`_ (ajcerejeira@gmail.com)
1516
* `Akash Suresh <https://www.github.com/akash-suresh>`_ (akashsuresh36@gmail.com)
1617
* `Alex Gaynor <https://github.com/alex>`_
1718
* `Alex Stapleton <https://www.github.com/public>`_

hypothesis-python/RELEASE.rst

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
RELEASE_TYPE: minor
2+
3+
:func:`~hypothesis.extra.django.from_field` now supports ``UsernameField``
4+
from :mod:`django.contrib.auth.forms`.
5+
6+
Thanks to Afonso Silva for reporting and working on :issue:`3417`.

hypothesis-python/docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def setup(app):
8989
"sphinx": ("https://www.sphinx-doc.org/en/master/", None),
9090
}
9191

92-
autodoc_mock_imports = ["numpy", "pandas", "redis"]
92+
autodoc_mock_imports = ["numpy", "pandas", "redis", "django"]
9393

9494
codeautolink_autodoc_inject = False
9595
codeautolink_global_preface = """

hypothesis-python/docs/numpy.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Supported versions
4747
There is quite a lot of variation between pandas versions. We only
4848
commit to supporting the latest version of pandas, but older minor versions are
4949
supported on a "best effort" basis. Hypothesis is currently tested against
50-
and confirmed working with every Pandas minor version from 0.25 through to 1.3.
50+
and confirmed working with every Pandas minor version from 1.0 through to 1.4.
5151

5252
Releases that are not the latest patch release of their minor version are not
5353
tested or officially supported, but will probably also work unless you hit a

hypothesis-python/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def local_file(name):
5959
"dateutil": ["python-dateutil>=1.4"],
6060
"lark": ["lark-parser>=0.6.5"],
6161
"numpy": ["numpy>=1.9.0"],
62-
"pandas": ["pandas>=0.25"],
62+
"pandas": ["pandas>=1.0"],
6363
"pytest": ["pytest>=4.6"],
6464
"dpcontracts": ["dpcontracts>=0.4"],
6565
"redis": ["redis>=3.0.0"],

hypothesis-python/src/hypothesis/extra/django/_fields.py

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import django
1919
from django import forms as df
20+
from django.contrib.auth.forms import UsernameField
2021
from django.core.validators import (
2122
validate_ipv4_address,
2223
validate_ipv6_address,
@@ -223,6 +224,7 @@ def _for_binary(field):
223224
@register_for(dm.TextField)
224225
@register_for(df.CharField)
225226
@register_for(df.RegexField)
227+
@register_for(UsernameField)
226228
def _for_text(field):
227229
# We can infer a vastly more precise strategy by considering the
228230
# validators as well as the field type. This is a minimal proof of

hypothesis-python/src/hypothesis/extra/pytz.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import datetime as dt
2424

2525
import pytz
26-
from pytz.tzfile import StaticTzInfo
26+
from pytz.tzfile import StaticTzInfo # type: ignore # considered private by typeshed
2727

2828
from hypothesis import strategies as st
2929
from hypothesis.strategies._internal.utils import cacheable, defines_strategy

hypothesis-python/src/hypothesis/internal/conjecture/dfa/lstar.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def __init__(self, member):
142142

143143
# When we're trying to figure out what state a string leads to we will
144144
# end up searching to find a suitable candidate. By putting states in
145-
# a self-organisating list we ideally minimise the number of lookups.
145+
# a self-organising list we ideally minimise the number of lookups.
146146
self.__self_organising_states = SelfOrganisingList(self.__states)
147147

148148
self.start = 0

hypothesis-python/tests/django/toystore/forms.py

+9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# obtain one at https://mozilla.org/MPL/2.0/.
1010

1111
from django import forms
12+
from django.contrib.auth.forms import ReadOnlyPasswordHashField, UsernameField
1213
from django.core.validators import (
1314
MaxLengthValidator,
1415
MaxValueValidator,
@@ -212,3 +213,11 @@ def __init__(self, subfield_count=12, **kwargs):
212213

213214
class ShortStringForm(ReprForm):
214215
_not_too_long = forms.CharField(max_length=20, required=False)
216+
217+
218+
class UsernameForm(ReprForm):
219+
username = UsernameField()
220+
221+
222+
class ReadOnlyPasswordHashFieldForm(ReprForm):
223+
password = ReadOnlyPasswordHashField()

hypothesis-python/tests/django/toystore/test_given_forms.py

+9
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
SlugFieldForm,
3030
TemporalFieldForm,
3131
URLFieldForm,
32+
UsernameForm,
3233
UUIDFieldForm,
3334
WithValidatorsForm,
3435
)
@@ -118,3 +119,11 @@ def test_tight_validators_form(self, x):
118119
self.assertTrue(1 <= x.data["_decimal_one_to_five"] <= 5)
119120
self.assertTrue(1 <= x.data["_float_one_to_five"] <= 5)
120121
self.assertTrue(5 <= len(x.data["_string_five_to_ten"]) <= 10)
122+
123+
@given(from_form(UsernameForm))
124+
def test_username_form(self, username_form):
125+
self.assertTrue(username_form.is_valid())
126+
127+
@given(from_form(UsernameForm))
128+
def test_read_only_password_hash_field_form(self, password_form):
129+
self.assertTrue(password_form.is_valid())

hypothesis-python/tests/nocover/test_regex.py

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def conservative_regex(draw):
4747
assume(COMBINED_MATCHER.search(result) is None)
4848
control = sum(result.count(c) for c in "?+*")
4949
assume(control <= 3)
50+
assume(I_WITH_DOT not in result) # known to be weird
5051
return result
5152

5253

hypothesis-python/tox.ini

+11-11
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,12 @@ commands=
4242
python -bb -X dev -m pytest tests/quality/ -n auto
4343

4444
# Note: when adding or removing tested Pandas versions, make sure to update the
45-
# docs in numpy.py too. To see current download rates of each minor version:
46-
# https://pepy.tech/project/pandas?versions=0.25.*&versions=1.0.*&versions=1.1.*&versions=1.2.*&versions=1.3.*
47-
[testenv:pandas25]
48-
deps =
49-
-r../requirements/test.txt
50-
pandas~=0.25.0
51-
commands =
52-
python -bb -X dev -m pytest tests/pandas -n auto
53-
45+
# docs in numpy.rst too. To see current download rates of each minor version:
46+
# https://pepy.tech/project/pandas?versions=0.25.*&versions=1.0.*&versions=1.1.*&versions=1.2.*&versions=1.3.*&versions=1.4.*
5447
[testenv:pandas10]
5548
deps =
5649
-r../requirements/test.txt
57-
pandas~=1.0.0
50+
pandas~=1.0.5
5851
commands =
5952
python -bb -X dev -m pytest tests/pandas -n auto
6053

@@ -75,7 +68,14 @@ commands =
7568
[testenv:pandas13]
7669
deps =
7770
-r../requirements/test.txt
78-
pandas~=1.3.4
71+
pandas~=1.3.5
72+
commands =
73+
python -bb -X dev -m pytest tests/pandas -n auto
74+
75+
[testenv:pandas14]
76+
deps =
77+
-r../requirements/test.txt
78+
pandas~=1.4.3
7979
commands =
8080
python -bb -X dev -m pytest tests/pandas -n auto
8181
# Adding a new pandas? See comment above!

requirements/coverage.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ exceptiongroup==1.0.0rc8 ; python_version < "3.11"
2828
# via hypothesis (hypothesis-python/setup.py)
2929
execnet==1.9.0
3030
# via pytest-xdist
31-
fakeredis==1.8.1
31+
fakeredis==1.8.2
3232
# via -r requirements/coverage.in
3333
iniconfig==1.1.1
3434
# via pytest

requirements/tools.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ flake8-helper==0.2.1
111111
# via flake8-strftime
112112
flake8-mutable==1.2.0
113113
# via -r requirements/tools.in
114-
flake8-noqa==1.2.5
114+
flake8-noqa==1.2.7
115115
# via -r requirements/tools.in
116116
flake8-pie==0.15.0
117117
# via -r requirements/tools.in
@@ -170,7 +170,7 @@ matplotlib-inline==0.1.3
170170
# via ipython
171171
mccabe==0.6.1
172172
# via flake8
173-
mypy==0.961
173+
mypy==0.971
174174
# via -r requirements/tools.in
175175
mypy-extensions==0.4.3
176176
# via
@@ -239,15 +239,15 @@ pygments==2.12.0
239239
# sphinx
240240
pyparsing==3.0.9
241241
# via packaging
242-
pyright==1.1.261
242+
pyright==1.1.263
243243
# via -r requirements/tools.in
244244
pytest==7.1.2
245245
# via -r requirements/tools.in
246246
python-dateutil==2.8.2
247247
# via -r requirements/tools.in
248248
pytz==2022.1
249249
# via babel
250-
pyupgrade==2.37.1
250+
pyupgrade==2.37.2
251251
# via shed
252252
pyyaml==6.0
253253
# via
@@ -347,9 +347,9 @@ types-click==7.1.8
347347
# via -r requirements/tools.in
348348
types-pkg-resources==0.1.3
349349
# via -r requirements/tools.in
350-
types-pytz==2022.1.1
350+
types-pytz==2022.1.2
351351
# via -r requirements/tools.in
352-
types-redis==4.3.4
352+
types-redis==4.3.11
353353
# via -r requirements/tools.in
354354
typing-extensions==4.3.0
355355
# via

tooling/src/hypothesistooling/__main__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def standard_tox_task(name):
440440

441441
for n in [22, 32, 40]:
442442
standard_tox_task(f"django{n}")
443-
for n in [25, 10, 11, 12, 13]:
443+
for n in [10, 11, 12, 13, 14]:
444444
standard_tox_task(f"pandas{n}")
445445

446446
standard_tox_task("coverage")

0 commit comments

Comments
 (0)