Skip to content

Commit

Permalink
Fix warning in test
Browse files Browse the repository at this point in the history
  • Loading branch information
Erotemic committed Aug 9, 2021
1 parent a5b264f commit 0e94adf
Showing 1 changed file with 65 additions and 56 deletions.
121 changes: 65 additions & 56 deletions testing/test_traceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,78 +7,87 @@


def test_fail_call_onefunc():
text = _run_case(utils.codeblock(
'''
def func(a):
"""
Example:
>>> a = 1
>>> func(a)
"""
a = []()
return a
'''))
assert '>>> func(a)' in text
assert 'rel: 2, abs: 5' in text
import warnings
with warnings.catch_warnings():
warnings.simplefilter("ignore")
text = _run_case(utils.codeblock(
'''
def func(a):
"""
Example:
>>> a = 1
>>> func(a)
"""
a = []()
return a
'''))
assert '>>> func(a)' in text
assert 'rel: 2, abs: 5' in text


def test_fail_call_twofunc():
"""
python ~/code/xdoctest/testing/test_traceback.py test_fail_call_twofunc
"""
text = _run_case(utils.codeblock(
'''
def func(a):
"""
Example:
>>> a = 1
>>> func(a)
"""
a = []()
return a
import warnings
with warnings.catch_warnings():
warnings.simplefilter("ignore")
text = _run_case(utils.codeblock(
'''
def func(a):
"""
Example:
>>> a = 1
>>> func(a)
"""
a = []()
return a
def func2(a):
"""
Example:
>>> pass
"""
pass
'''))
assert text
assert '>>> func(a)' in text
assert 'rel: 2, abs: 5,' in text
def func2(a):
"""
Example:
>>> pass
"""
pass
'''))
assert text
assert '>>> func(a)' in text
assert 'rel: 2, abs: 5,' in text


def test_fail_inside_twofunc():
"""
python ~/code/xdoctest/testing/test_traceback.py test_fail_inside_twofunc
"""
text = _run_case(utils.codeblock(
'''
def func(a):
"""
Example:
>>> print('not failed')
>>> # just a comment
>>> print(("foo"
... "bar"))
>>> a = []()
>>> func(a)
"""
return a
import warnings
with warnings.catch_warnings():
warnings.simplefilter("ignore")
text = _run_case(utils.codeblock(
'''
def func(a):
"""
Example:
>>> print('not failed')
>>> # just a comment
>>> print(("foo"
... "bar"))
>>> a = []()
>>> func(a)
"""
return a
def func2(a):
"""
Example:
>>> pass
"""
pass
'''))
assert text
assert '>>> a = []()' in text
assert 'rel: 5, abs: 8' in text
def func2(a):
"""
Example:
>>> pass
"""
pass
'''))
assert text
assert '>>> a = []()' in text
assert 'rel: 5, abs: 8' in text


def test_fail_inside_onefunc():
Expand Down

0 comments on commit 0e94adf

Please sign in to comment.