def test_verbose_has_double_colon(self, testdir): testdir.makepyfile(""" def test_true(): assert True """) output = testdir.runpytest('--force-sugar', '--verbose').stdout.str() assert 'test_verbose_has_double_colon.py::test_true' in strip_colors( output)
def test_new_summary(self, testdir): testdir.makepyfile(""" import pytest def test_sample(): assert False """) output = testdir.runpytest('--force-sugar').stdout.str() assert 'test_new_summary.py:3 test_sample' in strip_colors(output)
def test_old_summary(self, testdir): testdir.makepyfile( """ import pytest def test_sample(): assert False """ ) output = testdir.runpytest( '--force-sugar', '--old-summary' ).stdout.str() assert 'test_old_summary.py:4: assert False' in strip_colors(output)
def test_verbose_has_double_colon(self, testdir): testdir.makepyfile( """ def test_true(): assert True """ ) output = testdir.runpytest( '--force-sugar', '--verbose' ).stdout.str() assert 'test_verbose_has_double_colon.py::test_true' in strip_colors( output )
def test_not_verbose_no_double_colon_filename(self, testdir): testdir.makepyfile( """ class TestTrue: def test_true(self): assert True """ ) output = testdir.runpytest( '--force-sugar' ).stdout.str() test_name = 'test_not_verbose_no_double_colon_filename.py' assert test_name in strip_colors(output)
def get_counts(stdout): output = strip_colors(stdout) def _get(x): m = re.search(r'\d %s' % x, output) if m: return m.group()[0] else: return 'n/a' return { x: _get(x) for x in ('passed', 'xpassed', 'failed', 'xfailed', 'deselected', 'error', 'rerun', 'skipped') }
def test_verbose_has_double_colon_with_class(self, testdir): testdir.makepyfile( """ class TestTrue: def test_true(self): assert True """ ) output = testdir.runpytest( '--force-sugar', '--verbose' ).stdout.str() test_name = ( 'test_verbose_has_double_colon_with_class.py::TestTrue::test_true') assert test_name in strip_colors(output)
def test_fail_in_fixture_and_test(self, testdir): testdir.makepyfile(""" import pytest def test_func(): assert False def test_func2(): assert False @pytest.fixture def failure(): return 3/0 def test_lol(failure): assert True """) assert_count(testdir) output = strip_colors(testdir.runpytest('--force-sugar').stdout.str()) assert output.count(' -') == 2
def test_fail_in_fixture_and_test(self, testdir): testdir.makepyfile( """ import pytest def test_func(): assert False def test_func2(): assert False @pytest.fixture def failure(): return 3/0 def test_lol(failure): assert True """ ) assert_count(testdir) output = strip_colors(testdir.runpytest('--force-sugar').stdout.str()) assert output.count(' -') == 2
def get_counts(stdout): output = strip_colors(stdout) def _get(x): m = re.search(r'\d %s' % x, output) if m: return m.group()[0] else: return 'n/a' return { x: _get(x) for x in ( 'passed', 'xpassed', 'failed', 'xfailed', 'deselected', 'error', 'rerun', 'skipped' ) }