-
Notifications
You must be signed in to change notification settings - Fork 578
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
35 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
RELEASE_TYPE: minor | ||
|
||
This release updates :func:`hypothesis.strategies.uuids` by introducing an | ||
``allow_nil`` argument, defaulting to ``False``. If ``allow_nil=True``, | ||
nil UUID would be generated more often | ||
This release adds an ``allow_nil`` argument to :func:`~hypothesis.strategies.uuids`, | ||
which you can use to... generate the nil UUID. Thanks to Shlok Gandhi for the patch! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# This file is part of Hypothesis, which may be found at | ||
# https://github.com/HypothesisWorks/hypothesis/ | ||
# | ||
# Copyright the Hypothesis Authors. | ||
# Individual contributors are listed in AUTHORS.rst and the git log. | ||
# | ||
# This Source Code Form is subject to the terms of the Mozilla Public License, | ||
# v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
# obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
import uuid | ||
|
||
import pytest | ||
|
||
from hypothesis import strategies as st | ||
from hypothesis.errors import InvalidArgument | ||
|
||
from tests.common.debug import assert_no_examples, find_any | ||
|
||
|
||
def test_no_nil_uuid_by_default(): | ||
assert_no_examples(st.uuids(), lambda x: x == uuid.UUID(int=0)) | ||
|
||
|
||
def test_can_generate_nil_uuid(): | ||
find_any(st.uuids(allow_nil=True), lambda x: x == uuid.UUID(int=0)) | ||
|
||
|
||
def test_can_only_allow_nil_uuid_with_none_version(): | ||
st.uuids(version=None, allow_nil=True).example() | ||
with pytest.raises(InvalidArgument): | ||
st.uuids(version=4, allow_nil=True).example() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters