diff --git a/py/test/session.py b/py/test/session.py index c975fe243..9322f04bc 100644 --- a/py/test/session.py +++ b/py/test/session.py @@ -33,7 +33,7 @@ def itemgen(session, colitems, reporter, keyword=None): if isinstance(next, stopitems): try: next._skipbykeyword(keyword) - if session.config.option.keyword_oneshot: + if session and session.config.option.keyword_oneshot: keyword = None yield next except Skipped: diff --git a/py/test/testing/setupdata.py b/py/test/testing/setupdata.py index 79c0be964..29cfa3987 100644 --- a/py/test/testing/setupdata.py +++ b/py/test/testing/setupdata.py @@ -91,6 +91,19 @@ namecontent = [ def test_three(): assert 1 ''')), + ('testevenmore.py', py.code.Source(''' + def test_one(): + assert 1 + + def test_two(): + assert 1 + + def test_three(): + assert 1 + + def test_four(): + assert 1 + ''')), ('testspecial_importerror.py', py.code.Source(''' diff --git a/py/test/testing/test_session.py b/py/test/testing/test_session.py index 14b88b8b9..d0ea70d27 100644 --- a/py/test/testing/test_session.py +++ b/py/test/testing/test_session.py @@ -118,13 +118,13 @@ class TestKeywordSelection: assert l[0].item.name == 'test_1' def test_select_starton(self): - config = py.test.config._reparse([datadir/'testmore.py', - '-j', '-k', "test_two"]) + config = py.test.config._reparse([datadir/'testevenmore.py', + '-j', '-k', "test_three"]) all = [] session = config._getsessionclass()(config) session.main(all.append) assert len(getpassed(all)) == 2 - assert len(getskipped(all)) == 1 + assert len(getskipped(all)) == 2 class TestTerminalSession: