| 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 |
pytest_plugins = "pytester" |
| 12 |
|
| 13 |
|
| 14 |
TESTSUITE = """ |
| 15 |
from hypothesis import given |
| 16 |
from hypothesis.strategies import integers |
| 17 |
|
| 18 |
@given(integers()) |
| 19 |
def test_foo(x): |
| 20 |
pass |
| 21 |
|
| 22 |
def test_bar(): |
| 23 |
pass |
| 24 |
""" |
| 25 |
|
| 26 |
|
| 27 |
def test_can_select_mark(testdir): |
| 28 |
script = testdir.makepyfile(TESTSUITE) |
| 29 |
result = testdir.runpytest( |
| 30 |
script, "--verbose", "--strict-markers", "-m", "hypothesis" |
| 31 |
) |
| 32 |
out = "\n".join(result.stdout.lines) |
| 33 |
assert "1 passed, 1 deselected" in out |
| 34 |
|
| 35 |
|
| 36 |
UNITTEST_TESTSUITE = """ |
| 37 |
from hypothesis import given |
| 38 |
from hypothesis.strategies import integers |
| 39 |
from unittest import TestCase |
| 40 |
|
| 41 |
class TestStuff(TestCase): |
| 42 |
@given(integers()) |
| 43 |
def test_foo(self, x): |
| 44 |
pass |
| 45 |
|
| 46 |
def test_bar(self): |
| 47 |
pass |
| 48 |
""" |
| 49 |
|
| 50 |
|
| 51 |
def test_can_select_mark_on_unittest(testdir): |
| 52 |
script = testdir.makepyfile(UNITTEST_TESTSUITE) |
| 53 |
result = testdir.runpytest( |
| 54 |
script, "--verbose", "--strict-markers", "-m", "hypothesis" |
| 55 |
) |
| 56 |
out = "\n".join(result.stdout.lines) |
| 57 |
assert "1 passed, 1 deselected" in out |