Fix bug with wrong test description prosessing

After _process_docstring will be called for some item,
as a result docstring will be updated and it returns new docstring
that will be cutted, so info about next items will be lost.

Closes-Bug: #1434170
Change-Id: Iad13706855b476eac37157e88a1d92a864b10e9e
This commit is contained in:
Anastasia Kuznetsova 2015-03-19 19:38:25 +04:00
parent b9a090c716
commit b439a21b0c
2 changed files with 30 additions and 2 deletions

View File

@ -52,7 +52,8 @@ def _process_docstring(docstring, pattern):
if pattern_matcher:
value = pattern_matcher.group(1)
docstring = docstring[:pattern_matcher.start()]
docstring = (docstring[:pattern_matcher.start()] +
docstring[pattern_matcher.end():])
else:
value = None

View File

@ -13,11 +13,14 @@
# under the License.
from mock import Mock
from nose import case
from fuel_plugin.ostf_adapter.nose_plugin import nose_discovery
from fuel_plugin.ostf_adapter.nose_plugin import nose_utils
from fuel_plugin.ostf_adapter.storage import models
from fuel_plugin.testing.tests import base
TEST_PATH = 'fuel_plugin/testing/fixture/dummy_tests'
@ -96,7 +99,6 @@ class TestNoseDiscovery(base.BaseUnitTest):
'deployment_tags': ['ha', 'rhel']
}
test = [t for t in self.tests if t.name == expected['name']][0]
self.assertTrue(
@ -198,3 +200,28 @@ class TestNoseDiscovery(base.BaseUnitTest):
needed_test = self._find_needed_test(test['name'])
self.assertEqual(needed_test.available_since_release,
test['available_since_release'])
def test_description_parsing(self):
test_obj = Mock(spec=case.Test(Mock()))
test_obj.test._testMethodDoc = """
Dummy Test
Available since release: 2014.2-6.1
Duration: 180 s.
Scenario:
1. Step 1
Deployment tags: Dummy Tags
"""
data = nose_utils.get_description(test_obj)
expected = {
'duration': '180 s.',
'title': '',
'deployment_tags': ['dummy tags'],
'available_since_release': '2014.2-6.1'
}
for key in expected:
self.assertEqual(data[key], expected[key])
self.assertNotIn('Duration', data['description'])