-
Notifications
You must be signed in to change notification settings - Fork 575
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2126 from pckroon/fix_1996
Implement pytest.mark.parametrize detection. Fix #1996
- Loading branch information
Showing
7 changed files
with
68 additions
and
6 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
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,12 @@ | ||
RELEASE_TYPE: minor | ||
|
||
This release fixes a bug where our example database logic did not distinguish | ||
between failing examples based on arguments from a ``@pytest.mark.parametrize(...)``. | ||
This could in theory cause data loss if a common failure overwrote a rare one, and | ||
in practice caused occasional file-access collisions in highly concurrent workloads | ||
(e.g. during a 300-way parametrize on 16 cores). | ||
|
||
For internal reasons this also involves bumping the minimum supported version of | ||
:pypi:`pytest` to 4.3 | ||
|
||
Thanks to Peter C Kroon for the Hacktoberfest 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
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
44 changes: 44 additions & 0 deletions
44
hypothesis-python/tests/pytest/test_parametrized_db_keys.py
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,44 @@ | ||
# coding=utf-8 | ||
# | ||
# This file is part of Hypothesis, which may be found at | ||
# https://github.com/HypothesisWorks/hypothesis/ | ||
# | ||
# Most of this work is copyright (C) 2013-2019 David R. MacIver | ||
# (david@drmaciver.com), but it contains contributions by others. See | ||
# CONTRIBUTING.rst for a full list of people who may hold copyright, and | ||
# consult the git log if you need to determine who owns an individual | ||
# contribution. | ||
# | ||
# 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/. | ||
# | ||
# END HEADER | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
||
DB_KEY_TESTCASE = """ | ||
from hypothesis import settings, given | ||
from hypothesis.database import InMemoryExampleDatabase | ||
from hypothesis.strategies import booleans | ||
import pytest | ||
DB = InMemoryExampleDatabase() | ||
@settings(database=DB) | ||
@given(booleans()) | ||
@pytest.mark.parametrize("hi", (1, 2, 3)) | ||
@pytest.mark.xfail() | ||
def test_dummy_for_parametrized_db_keys(hi, i): | ||
assert Fail # Test *must* fail for it to end up the database anyway | ||
def test_DB_keys_for_parametrized_test(): | ||
assert len(DB.data) == 3 | ||
""" | ||
|
||
|
||
def test_db_keys_for_parametrized_tests_are_unique(testdir): | ||
script = testdir.makepyfile(DB_KEY_TESTCASE) | ||
testdir.runpytest(script).assert_outcomes(xfailed=3, passed=1) |
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
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