diff --git a/steadymark/__init__.py b/steadymark/__init__.py
index fdbab4c..6e42263 100644
--- a/steadymark/__init__.py
+++ b/steadymark/__init__.py
@@ -112,7 +112,7 @@ class MarkdownTest(object):
class SteadyMark(BaseRenderer):
- title_regex = re.compile(ur'(?P
.*)(?:[#]+(?P\d+))?')
+ title_regex = re.compile(ur'(?P[^#]+)(?:[#]+(?P\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:
diff --git a/tests/unit/test_parser.py b/tests/unit/test_parser.py
index 5793737..2e96f0a 100644
--- a/tests/unit/test_parser.py
+++ b/tests/unit/test_parser.py
@@ -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")