separate out the duration tests
This commit is contained in:
parent
29bf205f3a
commit
a324826dfd
|
@ -465,8 +465,8 @@ class TestInvocationVariants:
|
|||
"*1 failed*",
|
||||
])
|
||||
|
||||
def test_duration_test(testdir):
|
||||
testdir.makepyfile("""
|
||||
class TestDurations:
|
||||
source = """
|
||||
import time
|
||||
frag = 0.01
|
||||
def test_2():
|
||||
|
@ -475,7 +475,10 @@ def test_duration_test(testdir):
|
|||
time.sleep(frag)
|
||||
def test_3():
|
||||
time.sleep(frag*3)
|
||||
""")
|
||||
"""
|
||||
|
||||
def test_calls(self, testdir):
|
||||
testdir.makepyfile(self.source)
|
||||
result = testdir.runpytest("--durations=10")
|
||||
assert result.ret == 0
|
||||
result.stdout.fnmatch_lines([
|
||||
|
@ -486,6 +489,8 @@ def test_duration_test(testdir):
|
|||
])
|
||||
assert "remaining in" not in result.stdout.str()
|
||||
|
||||
def test_calls_show_2(self, testdir):
|
||||
testdir.makepyfile(self.source)
|
||||
result = testdir.runpytest("--durations=2")
|
||||
assert result.ret == 0
|
||||
result.stdout.fnmatch_lines([
|
||||
|
@ -495,6 +500,9 @@ def test_duration_test(testdir):
|
|||
"*s*%*remaining in 7 test phases",
|
||||
])
|
||||
assert "test_1" not in result.stdout.str()
|
||||
|
||||
def test_calls_showall(self, testdir):
|
||||
testdir.makepyfile(self.source)
|
||||
result = testdir.runpytest("--durations=0")
|
||||
assert result.ret == 0
|
||||
for x in "123":
|
||||
|
@ -506,8 +514,18 @@ def test_duration_test(testdir):
|
|||
else:
|
||||
raise AssertionError("not found %s %s" % (x,y))
|
||||
|
||||
def test_duration_test_with_fixture(testdir):
|
||||
testdir.makepyfile("""
|
||||
def test_with_deselected(self, testdir):
|
||||
testdir.makepyfile(self.source)
|
||||
result = testdir.runpytest("--durations=2", "-k test_1")
|
||||
assert result.ret == 0
|
||||
result.stdout.fnmatch_lines([
|
||||
"*durations*",
|
||||
"*call*test_1*",
|
||||
])
|
||||
|
||||
|
||||
class TestDurationWithFixture:
|
||||
source = """
|
||||
import time
|
||||
frag = 0.01
|
||||
def setup_function(func):
|
||||
|
@ -517,9 +535,12 @@ def test_duration_test_with_fixture(testdir):
|
|||
time.sleep(frag*2)
|
||||
def test_2():
|
||||
time.sleep(frag)
|
||||
""")
|
||||
"""
|
||||
def test_setup_function(self, testdir):
|
||||
testdir.makepyfile(self.source)
|
||||
result = testdir.runpytest("--durations=10")
|
||||
assert result.ret == 0
|
||||
|
||||
result.stdout.fnmatch_lines([
|
||||
"*durations*",
|
||||
"*setup*test_1*",
|
||||
|
@ -528,10 +549,3 @@ def test_duration_test_with_fixture(testdir):
|
|||
"*call*test_2*",
|
||||
])
|
||||
|
||||
result = testdir.runpytest("--durations=2", "-k test_1")
|
||||
assert result.ret == 0
|
||||
result.stdout.fnmatch_lines([
|
||||
"*durations*",
|
||||
"*call*test_1*",
|
||||
])
|
||||
|
||||
|
|
Loading…
Reference in New Issue