Merge pull request #6143 from blueyed/test_source
test_source: do not instantiate Source objects during collection
This commit is contained in:
commit
14eaa05b60
|
@ -127,14 +127,15 @@ def test_isparseable():
|
||||||
|
|
||||||
|
|
||||||
class TestAccesses:
|
class TestAccesses:
|
||||||
source = Source(
|
def setup_class(self):
|
||||||
"""\
|
self.source = Source(
|
||||||
def f(x):
|
"""\
|
||||||
pass
|
def f(x):
|
||||||
def g(x):
|
pass
|
||||||
pass
|
def g(x):
|
||||||
"""
|
pass
|
||||||
)
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
def test_getrange(self):
|
def test_getrange(self):
|
||||||
x = self.source[0:2]
|
x = self.source[0:2]
|
||||||
|
@ -155,14 +156,15 @@ class TestAccesses:
|
||||||
|
|
||||||
|
|
||||||
class TestSourceParsingAndCompiling:
|
class TestSourceParsingAndCompiling:
|
||||||
source = Source(
|
def setup_class(self):
|
||||||
"""\
|
self.source = Source(
|
||||||
def f(x):
|
"""\
|
||||||
assert (x ==
|
def f(x):
|
||||||
3 +
|
assert (x ==
|
||||||
4)
|
3 +
|
||||||
"""
|
4)
|
||||||
).strip()
|
"""
|
||||||
|
).strip()
|
||||||
|
|
||||||
def test_compile(self):
|
def test_compile(self):
|
||||||
co = _pytest._code.compile("x=3")
|
co = _pytest._code.compile("x=3")
|
||||||
|
@ -619,7 +621,8 @@ x = 3
|
||||||
|
|
||||||
|
|
||||||
class TestTry:
|
class TestTry:
|
||||||
source = """\
|
def setup_class(self):
|
||||||
|
self.source = """\
|
||||||
try:
|
try:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
except Something:
|
except Something:
|
||||||
|
@ -646,7 +649,8 @@ else:
|
||||||
|
|
||||||
|
|
||||||
class TestTryFinally:
|
class TestTryFinally:
|
||||||
source = """\
|
def setup_class(self):
|
||||||
|
self.source = """\
|
||||||
try:
|
try:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
finally:
|
finally:
|
||||||
|
@ -663,7 +667,8 @@ finally:
|
||||||
|
|
||||||
|
|
||||||
class TestIf:
|
class TestIf:
|
||||||
source = """\
|
def setup_class(self):
|
||||||
|
self.source = """\
|
||||||
if 1:
|
if 1:
|
||||||
y = 3
|
y = 3
|
||||||
elif False:
|
elif False:
|
||||||
|
|
Loading…
Reference in New Issue