From c491a708e0b07a08e052fc52d78d1467d1f1f965 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Wed, 24 Jun 2009 16:04:42 +0200 Subject: [PATCH] add test and fix keyword recogniation, thanks Andreas Kloeckner --HG-- branch : 1.0.x --- CHANGELOG | 5 +++-- py/test/collect.py | 2 +- py/test/testing/test_genitems.py | 13 +++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6a6d151ea..a9ff36b22 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,8 +6,9 @@ Changes between 1.0.0b3 and 1.0.0 * perform setup finalization before reporting failures -* apply modified from Andreas Kloeckner to allow - test functions to have no func_code +* apply modified patches from Andreas Kloeckner to allow + test functions to have no func_code (#22) and to make + "-k" and function keywords work (#20) Changes between 1.0.0b1 and 1.0.0b3 ============================================= diff --git a/py/test/collect.py b/py/test/collect.py index 33611274d..a56ec496c 100644 --- a/py/test/collect.py +++ b/py/test/collect.py @@ -204,7 +204,7 @@ class Node(object): def _matchonekeyword(self, key, chain): elems = key.split(".") # XXX O(n^2), anyone cares? - chain = [item._keywords() for item in chain if item._keywords()] + chain = [item.readkeywords() for item in chain if item._keywords()] for start, _ in enumerate(chain): if start + len(elems) > len(chain): return False diff --git a/py/test/testing/test_genitems.py b/py/test/testing/test_genitems.py index f917e5386..ebe7a9f6f 100644 --- a/py/test/testing/test_genitems.py +++ b/py/test/testing/test_genitems.py @@ -121,3 +121,16 @@ class TestKeywordSelection: item = dlist[0].items[0] assert item.name == "test_one" + + def test_keyword_extra(self, testdir): + p = testdir.makepyfile(""" + def test_one(): + assert 0 + test_one.mykeyword = True + """) + reprec = testdir.inline_run("-k", "-mykeyword", p) + passed, skipped, failed = reprec.countoutcomes() + assert passed + skipped + failed == 0 + reprec = testdir.inline_run("-k", "mykeyword", p) + passed, skipped, failed = reprec.countoutcomes() + assert failed == 1