add test and fix keyword recogniation, thanks Andreas Kloeckner

--HG--
branch : 1.0.x
This commit is contained in:
holger krekel 2009-06-24 16:04:42 +02:00
parent f531a1d6c9
commit c491a708e0
3 changed files with 17 additions and 3 deletions

View File

@ -6,8 +6,9 @@ Changes between 1.0.0b3 and 1.0.0
* perform setup finalization before reporting failures * perform setup finalization before reporting failures
* apply modified from Andreas Kloeckner to allow * apply modified patches from Andreas Kloeckner to allow
test functions to have no func_code 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 Changes between 1.0.0b1 and 1.0.0b3
============================================= =============================================

View File

@ -204,7 +204,7 @@ class Node(object):
def _matchonekeyword(self, key, chain): def _matchonekeyword(self, key, chain):
elems = key.split(".") elems = key.split(".")
# XXX O(n^2), anyone cares? # 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): for start, _ in enumerate(chain):
if start + len(elems) > len(chain): if start + len(elems) > len(chain):
return False return False

View File

@ -121,3 +121,16 @@ class TestKeywordSelection:
item = dlist[0].items[0] item = dlist[0].items[0]
assert item.name == "test_one" 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