1
- import pytest
1
+ from __future__ import annotations
2
+
2
3
import textwrap
3
4
5
+
4
6
def test_discover_imports_enabled (pytester ):
5
7
src_dir = pytester .mkdir ("src" )
6
8
tests_dir = pytester .mkdir ("tests" )
@@ -12,18 +14,21 @@ def test_discover_imports_enabled(pytester):
12
14
13
15
src_file = src_dir / "foo.py"
14
16
15
- src_file .write_text (textwrap .dedent ("""\
17
+ src_file .write_text (
18
+ textwrap .dedent ("""\
16
19
class TestClass(object):
17
20
def __init__(self):
18
21
super().__init__()
19
22
20
23
def test_foobar(self):
21
24
return true
22
- """
23
- ), encoding = "utf-8" )
25
+ """ ),
26
+ encoding = "utf-8" ,
27
+ )
24
28
25
29
test_file = tests_dir / "foo_test.py"
26
- test_file .write_text (textwrap .dedent ("""\
30
+ test_file .write_text (
31
+ textwrap .dedent ("""\
27
32
import sys
28
33
import os
29
34
@@ -38,13 +43,15 @@ class TestDomain:
38
43
def test_testament(self):
39
44
testament = TestClass()
40
45
pass
41
- """ ), encoding = "utf-8" )
46
+ """ ),
47
+ encoding = "utf-8" ,
48
+ )
42
49
43
50
result = pytester .runpytest ()
44
51
result .assert_outcomes (errors = 1 )
45
52
53
+
46
54
def test_discover_imports_disabled (pytester ):
47
-
48
55
src_dir = pytester .mkdir ("src" )
49
56
tests_dir = pytester .mkdir ("tests" )
50
57
pytester .makeini ("""
@@ -55,19 +62,22 @@ def test_discover_imports_disabled(pytester):
55
62
56
63
src_file = src_dir / "foo.py"
57
64
58
- src_file .write_text (textwrap .dedent ("""\
65
+ src_file .write_text (
66
+ textwrap .dedent ("""\
59
67
class Testament(object):
60
68
def __init__(self):
61
69
super().__init__()
62
70
self.collections = ["stamp", "coin"]
63
71
64
72
def personal_property(self):
65
73
return [f"my {x} collection" for x in self.collections]
66
- """
67
- ), encoding = "utf-8" )
74
+ """ ),
75
+ encoding = "utf-8" ,
76
+ )
68
77
69
78
test_file = tests_dir / "foo_test.py"
70
- test_file .write_text (textwrap .dedent ("""\
79
+ test_file .write_text (
80
+ textwrap .dedent ("""\
71
81
import sys
72
82
import os
73
83
@@ -82,7 +92,9 @@ class TestDomain:
82
92
def test_testament(self):
83
93
testament = Testament()
84
94
assert testament.personal_property()
85
- """ ), encoding = "utf-8" )
95
+ """ ),
96
+ encoding = "utf-8" ,
97
+ )
86
98
87
99
result = pytester .runpytest ()
88
- result .assert_outcomes (passed = 1 )
100
+ result .assert_outcomes (passed = 1 )
0 commit comments