fixing bug related to the indexes titles of headers containing more than one test

This commit is contained in:
Gabriel Falcao 2012-09-06 23:32:47 -04:00
parent e55f8cf892
commit 49f2cd8c3f
2 changed files with 12 additions and 4 deletions

View File

@ -112,7 +112,7 @@ class MarkdownTest(object):
class SteadyMark(BaseRenderer):
title_regex = re.compile(ur'(?P<title>.*)(?:[#]+(?P<index>\d+))?')
title_regex = re.compile(ur'(?P<title>[^#]+)(?:[#]+(?P<index>\d+))?')
def preprocess(self, text):
self._tests = [{}]
@ -128,7 +128,7 @@ class SteadyMark(BaseRenderer):
item = self._tests[-1]
if 'code' in item: # the same title has more than 1 code
found = self.title_regex.search(item['title'])
title = found.group('title')
title = found.group('title').rstrip()
index = int(found.group('index') or 0)
if not index:

View File

@ -135,13 +135,18 @@ assert False, 'FIRST'
```python
assert False, 'SECOND'
```
```python
assert False, 'THIRD'
```
"""
sm = SteadyMark.inspect(md)
sm.tests.should.have.length_of(2)
sm.tests.should.have.length_of(3)
test1, test2 = sm.tests
test1, test2, test3 = sm.tests
test1.title.should.equal("Test Foo #1")
eval.when.called_with(test1.code).should.throw(AssertionError, "FIRST")
@ -149,6 +154,9 @@ assert False, 'SECOND'
test2.title.should.equal("Test Foo #2")
eval.when.called_with(test2.code).should.throw(AssertionError, "SECOND")
test3.title.should.equal("Test Foo #3")
eval.when.called_with(test3.code).should.throw(AssertionError, "THIRD")
def test_skip_tests_marked_with_ignore():
(u"SteadyMark should skip tests with the 'ignore' modeline")