Skip to content

Commit c3c77e6

Browse files
committed
Formatting and cache busting
1 parent 263c044 commit c3c77e6

File tree

8 files changed

+18
-20
lines changed

8 files changed

+18
-20
lines changed

hypothesis-python/setup.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@ def local_file(name):
124124
"Topic :: Software Development :: Testing",
125125
"Typing :: Typed",
126126
],
127-
py_modules=["_hypothesis_pytestplugin", "_hypothesis_ftz_detector", "_hypothesis_globals"],
127+
py_modules=[
128+
"_hypothesis_pytestplugin",
129+
"_hypothesis_ftz_detector",
130+
"_hypothesis_globals",
131+
],
128132
entry_points={
129133
"pytest11": ["hypothesispytest = _hypothesis_pytestplugin"],
130134
"console_scripts": ["hypothesis = hypothesis.extra.cli:main"],

hypothesis-python/src/_hypothesis_globals.py

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import os
1717

18-
1918
in_initialization = 1
2019
"""If nonzero, indicates that hypothesis is still initializing (importing or loading
2120
the test environment). `import hypothesis` will cause this number to be decremented,

hypothesis-python/src/_hypothesis_pytestplugin.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@
2626
import warnings
2727
from inspect import signature
2828

29-
import pytest
30-
3129
import _hypothesis_globals
30+
import pytest
3231

3332
try:
3433
from _pytest.junitxml import xml_key

hypothesis-python/src/hypothesis/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"""
1717

1818
import _hypothesis_globals
19+
1920
from hypothesis._settings import HealthCheck, Phase, Verbosity, settings
2021
from hypothesis.control import (
2122
assume,

hypothesis-python/src/hypothesis/configuration.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from pathlib import Path
1414

1515
import _hypothesis_globals
16-
import hypothesis
16+
1717
from hypothesis.errors import HypothesisSideeffectWarning
1818

1919
__hypothesis_home_directory_default = Path.cwd() / ".hypothesis"
@@ -67,7 +67,7 @@ def check_sideeffect_during_initialization(what: str, extra: str = "") -> None:
6767
_first_postinit_what = what
6868

6969

70-
def notice_initialization_restarted(warn: bool = True) -> None:
70+
def notice_initialization_restarted(*, warn: bool = True) -> None:
7171
"""Reset _first_postinit_what, so that we don't think we're in post-init. Additionally, if it
7272
was set that means that there has been a sideeffect that we haven't warned about, so do that
7373
now (the warning text will be correct, and we also hint that the stacktrace can be improved).

hypothesis-python/src/hypothesis/database.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,9 @@ def _prepare_for_io(self) -> None:
495495
self._initialized = True
496496

497497
def _initialize_db(self) -> None:
498+
# Trigger warning that we suppressed earlier by intent_to_write=False
499+
storage_directory(self.path.name)
498500
# Create the cache directory if it doesn't exist
499-
storage_directory(self.path.name) # trigger warning that we suppressed earlier with intent_to_write=False
500501
self.path.mkdir(exist_ok=True, parents=True)
501502

502503
# Get all artifacts

hypothesis-python/src/hypothesis/strategies/_internal/lazy.py

-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@
88
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
99
# obtain one at https://mozilla.org/MPL/2.0/.
1010

11-
import warnings
1211
from inspect import signature
1312
from typing import MutableMapping
1413
from weakref import WeakKeyDictionary
1514

1615
from hypothesis.configuration import check_sideeffect_during_initialization
17-
from hypothesis.errors import HypothesisSideeffectWarning
1816
from hypothesis.internal.reflection import (
1917
convert_keyword_arguments,
2018
convert_positional_arguments,

hypothesis-python/tests/cover/test_sideeffect_warnings.py

+7-11
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,11 @@
88
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
99
# obtain one at https://mozilla.org/MPL/2.0/.
1010

11-
from pathlib import Path
12-
import warnings
13-
11+
import _hypothesis_globals
1412
import pytest
1513

16-
import _hypothesis_globals
17-
from hypothesis import configuration as fs
14+
from hypothesis import configuration as fs, strategies as st
1815
from hypothesis.errors import HypothesisSideeffectWarning
19-
from hypothesis import strategies as st
2016

2117
IN_INITIALIZATION_ATTR = "in_initialization"
2218

@@ -30,7 +26,7 @@
3026

3127

3228
@pytest.fixture
33-
def extend_initialization(monkeypatch):
29+
def _extend_initialization(monkeypatch):
3430
assert getattr(_hypothesis_globals, IN_INITIALIZATION_ATTR) == 0
3531
monkeypatch.setattr(_hypothesis_globals, IN_INITIALIZATION_ATTR, 1)
3632
fs.notice_initialization_restarted(warn=False)
@@ -40,19 +36,19 @@ def extend_initialization(monkeypatch):
4036
@pytest.mark.parametrize(
4137
"sideeffect, warning_text",
4238
[
43-
(lambda: st.integers().wrapped_strategy, "lazy evaluation"),
39+
(lambda: st.builds(lambda: None).wrapped_strategy, "lazy evaluation"), # guaranteed not cached
4440
(lambda: st.deferred(st.integers).wrapped_strategy, "deferred evaluation"),
4541
(fs.storage_directory, "accessing storage"),
4642
],
4743
)
48-
def test_sideeffect_warning(sideeffect, warning_text, extend_initialization):
44+
def test_sideeffect_warning(sideeffect, warning_text, _extend_initialization):
4945
with pytest.warns(HypothesisSideeffectWarning, match=warning_text):
5046
sideeffect()
5147

5248

53-
def test_sideeffect_delayed_warning(monkeypatch, extend_initialization):
49+
def test_sideeffect_delayed_warning(monkeypatch, _extend_initialization):
5450
what = "synthetic side-effect"
55-
# extend_initialization ensures we start at known clean slate (no delayed warnings).
51+
# _extend_initialization ensures we start at known clean slate (no delayed warnings).
5652
# Then: stop initialization, check a side-effect operation, and restart it.
5753
monkeypatch.setattr(_hypothesis_globals, IN_INITIALIZATION_ATTR, 0)
5854
fs.check_sideeffect_during_initialization(what)

0 commit comments

Comments
 (0)