def test_fail_run_with_deselected(self): self.setupStep( step.Pytest(workdir='build', tests='testname', pytestMode="xdist", testpath=None)) self.expectCommands( ExpectShell(workdir='build', command=['py.test', '-v', 'testname'], usePTY="slave-config") + ExpectShell.log( 'stdio', stdout= """============================= test session starts ============================== platform linux2 -- Python 2.6.5 -- pytest-2.3.4 -- /usr/bin/python plugins: xdist collecting ... collected 11 items ------------------------------- Captured stderr -------------------------------- 2013-04-04 08:35:48,752 INFO Starting new HTTP connection (1): example.com ===== 6 tests deselected by "-m 'not failure and not skipped'" ===== ==== 1 failed, 4 passed, 6 deselected in 0.01 seconds ==== """) + 1) self.expectOutcome( result=FAILURE, status_text=['11 tests', '1 failure', '6 deselected']) return self.runStep()
def test_run_plural(self): self.setupStep( step.Pytest(workdir='build', tests='testname', testpath=None)) self.expectCommands( ExpectShell(workdir='build', command=['py.test', '-v', 'testname'], usePTY="slave-config") + ExpectShell.log('stdio', stdout="""collected 2 items ==== 2 passed in 11.1 seconds ===== """) + 0) self.expectOutcome(result=SUCCESS, status_text=['2 tests', 'passed']) return self.runStep()
def test_run_env_nodupe(self): self.setupStep( step.Pytest(workdir='build', tests='testname', testpath='path2', env={'PYTHONPATH': ['path1', 'path2']})) self.expectCommands( ExpectShell(workdir='build', command=['py.test', '-v', 'testname'], usePTY="slave-config", env=dict(PYTHONPATH=['path1', 'path2'])) + ExpectShell.log('stdio', stdout="collected 0 items\n") + 0) self.expectOutcome(result=SUCCESS, status_text=['no tests', 'run']) return self.runStep()
def test_run_plural_with_failures(self): self.setupStep( step.Pytest(workdir='build', tests='testname', testpath=None)) self.expectCommands( ExpectShell(workdir='build', command=['py.test', '-v', 'testname'], usePTY="slave-config") + ExpectShell.log('stdio', stdout="""collected 3 items ==== 1 failed, 2 passed, 0 skipped in 10.1 seconds ===== """) + 1) self.expectOutcome(result=FAILURE, status_text=['3 tests', '1 failure']) return self.runStep()
def test_pytest_problems(self): pytest_stdout = open(MODULE_DIR + "/fixture.stdout").read() pytest_problems = open(MODULE_DIR + "/fixture.problems").read() self.setupStep( step.Pytest(workdir='build', tests='testname', testpath=None)) self.expectCommands( ExpectShell(workdir='build', command=['py.test', '-v', 'testname'], usePTY="slave-config") + ExpectShell.log('stdio', stdout=pytest_stdout) + 1) self.expectOutcome(result=FAILURE, status_text=['9 tests', '3 failures', '2 skips']) self.expectLogfile(logfile='problems', contents=pytest_problems) return self.runStep()
def test_run_with_deselected(self): self.setupStep( step.Pytest(workdir='build', tests='testname', testpath=None)) self.expectCommands( ExpectShell(workdir='build', command=['py.test', '-v', 'testname'], usePTY="slave-config") + ExpectShell.log('stdio', stdout="""collected 11 items ===== 6 tests deselected by "-m 'not failure and not skipped'" ===== ==== 5 passed, 6 deselected in 0.01 seconds ==== """) + 0) self.expectOutcome(result=SUCCESS, status_text=['11 tests', 'passed', '6 deselected']) return self.runStep()
def test_run_with_passing_xfail(self): self.setupStep( step.Pytest(workdir='build', tests='testname', testpath=None)) self.expectCommands( ExpectShell(workdir='build', command=['py.test', '-v', 'testname'], usePTY="slave-config") + ExpectShell.log('stdio', stdout="""collecting ... collected 11 items ===== 3 failed, 4 passed, 2 skipped, 1 xfailed, 1 xpassed in 0.03 seconds ====== """) + 0) self.expectOutcome( result=SUCCESS, status_text=['11 tests', '2 skips', '1 todo', '1 surprises']) return self.runStep()
def test_run_with_error(self): self.setupStep( step.Pytest(workdir='build', tests='testname', testpath=None)) self.expectCommands( ExpectShell(workdir='build', command=['py.test', '-v', 'testname'], usePTY="slave-config") + ExpectShell.log('stdio', stdout="""collecting ... collected 11 items ================== 408 tests deselected by "-m 'serialtest'" =================== ======== 1 failed, 2 passed, 1 deselected, 3 error in 9.46 seconds ======== """) + 1) self.expectOutcome( result=FAILURE, status_text=['7 tests', '1 failure', '3 errors', '1 deselected']) return self.runStep()