Skip to content

Commit

Permalink
run doctests (via #93)
Browse files Browse the repository at this point in the history
  • Loading branch information
sseliverstov committed Jul 9, 2017
1 parent 5a31fe5 commit 35efcfc
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
10 changes: 8 additions & 2 deletions allure-python-commons-test/src/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def describe_mismatch(self, item, mismatch_descaription):

def has_container(report, *matchers):
"""
>>> from hamcrest import assert_that
>>> from allure_commons_test.report import has_test_case
>>> class Report(object):
... test_cases = [
... {
Expand Down Expand Up @@ -60,7 +64,7 @@ def has_container(report, *matchers):
... has_before('before_fixture')
... )
... )
... )
... ) # doctest: +ELLIPSIS
Traceback (most recent call last):
...
AssertionError: ...
Expand Down Expand Up @@ -104,6 +108,8 @@ def describe_to(self, description):

def has_same_container(*args):
"""
>>> from hamcrest import assert_that
>>> class Report(object):
... test_cases = [
... {
Expand Down Expand Up @@ -134,7 +140,7 @@ def has_same_container(*args):
>>> assert_that(Report,
... has_same_container('second_test_case', 'third_test_case')
... )
... ) # doctest: +ELLIPSIS
Traceback (most recent call last):
...
AssertionError: ...
Expand Down
6 changes: 1 addition & 5 deletions allure-python-commons-test/src/label.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
"""
No milk today my love has gone away;)
"""

from hamcrest import all_of
from hamcrest import has_entry, has_item

Expand Down Expand Up @@ -33,4 +29,4 @@ def has_story(story):


def has_tag(tag):
return has_label('tag', tag)
return has_label('tag', tag)
6 changes: 4 additions & 2 deletions allure-python-commons-test/src/report.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""
>>> from hamcrest import assert_that
>>> class Report(object):
... def __init__(self):
... self.test_cases = [
Expand Down Expand Up @@ -34,7 +36,7 @@
>>> assert_that(Report(),
... has_test_case('wrong_test_case_name')
... )
... ) # doctest: +ELLIPSIS
Traceback (most recent call last):
...
AssertionError: ...
Expand All @@ -54,7 +56,7 @@
... has_test_case('Class#test[param]',
... has_entry('id', '2')
... )
... )
... ) # doctest: +ELLIPSIS
Traceback (most recent call last):
...
AssertionError: ...
Expand Down
14 changes: 7 additions & 7 deletions allure-python-commons-test/src/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@
... }
... }
HAS STEP +
>>> assert_that(testcases['ideal_case'], has_step('step_one'))
HAS STEP +-
>>> assert_that(testcases['ideal_case'],
... has_step('ideal_case'),
... is_not(has_step('step_one')
... ))
... has_step('ideal_case'),
... is_not(has_step('step_one'))
... ) # doctest: +ELLIPSIS
Traceback (most recent call last):
...
AssertionError: ...
Expand All @@ -50,8 +49,9 @@
<BLANKLINE>
HAS STEP -
>>> assert_that(testcases['ideal_case'], has_step('wrong_steop_name'))
>>> assert_that(testcases['ideal_case'],
... has_step('wrong_step_name')
... ) # doctest: +ELLIPSIS
Traceback (most recent call last):
...
AssertionError: ...
Expand Down
4 changes: 4 additions & 0 deletions allure-python-commons-test/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ passenv =

commands=
python setup.py develop
python -m doctest -v ./src/container.py
python -m doctest -v ./src/report.py
python -m doctest -v ./src/label.py
python -m doctest -v ./src/result.py

0 comments on commit 35efcfc

Please sign in to comment.