| 1 |
# This file is part of Hypothesis, which may be found at |
| 2 |
# https://github.com/HypothesisWorks/hypothesis/ |
| 3 |
# |
| 4 |
# Copyright the Hypothesis Authors. |
| 5 |
# Individual contributors are listed in AUTHORS.rst and the git log. |
| 6 |
# |
| 7 |
# This Source Code Form is subject to the terms of the Mozilla Public License, |
| 8 |
# v. 2.0. If a copy of the MPL was not distributed with this file, You can |
| 9 |
# obtain one at https://mozilla.org/MPL/2.0/. |
| 10 |
|
| 11 |
import pytest |
| 12 |
|
| 13 |
from tests.common.utils import skipif_threading |
| 14 |
|
| 15 |
pytest_plugins = "pytester" |
| 16 |
|
| 17 |
INI = """ |
| 18 |
[pytest] |
| 19 |
norecursedirs = .svn tmp whatever* |
| 20 |
""" |
| 21 |
|
| 22 |
TEST_SCRIPT = """ |
| 23 |
def test_noop(): |
| 24 |
pass |
| 25 |
""" |
| 26 |
|
| 27 |
|
| 28 |
@pytest.mark.skipif(int(pytest.__version__.split(".")[0]) < 7, reason="hook is new") |
| 29 |
@skipif_threading # colliding test_bad.py file |
| 30 |
def test_collection_warning(pytester): |
| 31 |
pytester.mkdir(".hypothesis") |
| 32 |
pytester.path.joinpath("pytest.ini").write_text(INI, encoding="utf-8") |
| 33 |
pytester.path.joinpath("test_ok.py").write_text(TEST_SCRIPT, encoding="utf-8") |
| 34 |
pytester.path.joinpath(".hypothesis/test_bad.py").write_text( |
| 35 |
TEST_SCRIPT.replace("pass", "raise Exception"), encoding="utf-8" |
| 36 |
) |
| 37 |
|
| 38 |
result = pytester.runpytest_subprocess() |
| 39 |
result.assert_outcomes(passed=1, warnings=1) |
| 40 |
assert "Skipping collection of '.hypothesis'" in "\n".join(result.outlines) |