Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@NiklasMM
Created June 13, 2017 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NiklasMM/fe34154aad29e837e0efbd100647523d to your computer and use it in GitHub Desktop.
Save NiklasMM/fe34154aad29e837e0efbd100647523d to your computer and use it in GitHub Desktop.
pytest stacktrace
============================= test session starts ==============================
platform linux2 -- Python 2.7.12, pytest-3.1.2, py-1.4.34, pluggy-0.4.0
rootdir: /tmp/test, inifile:
collected 1 items
unicode_helper.py F
=================================== FAILURES ===================================
___________________ [doctest] unicode_helper.fix_bad_unicode ___________________
self = <CallInfo when='call' exception: 'ascii' codec can't encode character u'\xfa' in position 0: ordinal not in range(128)>
func = <function <lambda> at 0x7fe34f29c848>, when = 'call'
def __init__(self, func, when):
#: context of invocation: one of "setup", "call",
#: "teardown", "memocollect"
self.when = when
self.start = time()
try:
> self.result = func()
env/local/lib/python2.7/site-packages/_pytest/runner.py:157:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> return CallInfo(lambda: ihook(item=item, **kwds), when=when)
env/local/lib/python2.7/site-packages/_pytest/runner.py:145:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_HookCaller 'pytest_runtest_call'>
kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <DoctestItem 'unicode_helper.fix_bad_unicode'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <DoctestItem 'unicode_helper.fix_bad_unicode'>}
def __call__(self, **kwargs):
assert not self.is_historic()
> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
env/local/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py:745:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_pytest.config.PytestPluginManager object at 0x7fe34fef8f10>
hook = <_HookCaller 'pytest_runtest_call'>, methods = []
kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <DoctestItem 'unicode_helper.fix_bad_unicode'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <DoctestItem 'unicode_helper.fix_bad_unicode'>}
def _hookexec(self, hook, methods, kwargs):
# called from all hookcaller instances.
# enable_tracing will set its own wrapping function at self._inner_hookexec
> return self._inner_hookexec(hook, methods, kwargs)
env/local/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py:339:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
hook = <_HookCaller 'pytest_runtest_call'>, methods = []
kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <DoctestItem 'unicode_helper.fix_bad_unicode'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <DoctestItem 'unicode_helper.fix_bad_unicode'>}
self._inner_hookexec = lambda hook, methods, kwargs: \
> _MultiCall(methods, kwargs, hook.spec_opts).execute()
env/local/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py:334:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_MultiCall 0 results, 0 meths, kwargs={'item': <DoctestItem 'unicode_helper.fix_bad_unicode'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>
def execute(self):
all_kwargs = self.kwargs
self.results = results = []
firstresult = self.specopts.get("firstresult")
while self.hook_impls:
hook_impl = self.hook_impls.pop()
try:
args = [all_kwargs[argname] for argname in hook_impl.argnames]
except KeyError:
for argname in hook_impl.argnames:
if argname not in all_kwargs:
raise HookCallError(
"hook call must provide argument %r" % (argname,))
if hook_impl.hookwrapper:
> return _wrapped_call(hook_impl.function(*args), self.execute)
env/local/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py:613:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
wrap_controller = <generator object pytest_runtest_call at 0x7fe34f319280>
func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ad_unicode'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>>
def _wrapped_call(wrap_controller, func):
""" Wrap calling to a function with a generator which needs to yield
exactly once. The yield point will trigger calling the wrapped function
and return its _CallOutcome to the yield point. The generator then needs
to finish (raise StopIteration) in order for the wrapped call to complete.
"""
try:
next(wrap_controller) # first yield
except StopIteration:
_raise_wrapfail(wrap_controller, "did not yield")
call_outcome = _CallOutcome(func)
try:
wrap_controller.send(call_outcome)
_raise_wrapfail(wrap_controller, "has second yield")
except StopIteration:
pass
> return call_outcome.get_result()
env/local/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py:254:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0x7fe34f2ab5f0>
def get_result(self):
if self.excinfo is None:
return self.result
else:
ex = self.excinfo
if _py3:
raise ex[1].with_traceback(ex[2])
> _reraise(*ex) # noqa
env/local/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py:280:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0x7fe34f2ab5f0>
func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...ad_unicode'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>>
def __init__(self, func):
try:
> self.result = func()
env/local/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_MultiCall 0 results, 0 meths, kwargs={'item': <DoctestItem 'unicode_helper.fix_bad_unicode'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>
def execute(self):
all_kwargs = self.kwargs
self.results = results = []
firstresult = self.specopts.get("firstresult")
while self.hook_impls:
hook_impl = self.hook_impls.pop()
try:
args = [all_kwargs[argname] for argname in hook_impl.argnames]
except KeyError:
for argname in hook_impl.argnames:
if argname not in all_kwargs:
raise HookCallError(
"hook call must provide argument %r" % (argname,))
if hook_impl.hookwrapper:
return _wrapped_call(hook_impl.function(*args), self.execute)
> res = hook_impl.function(*args)
env/local/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py:614:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
item = <DoctestItem 'unicode_helper.fix_bad_unicode'>
def pytest_runtest_call(item):
try:
> item.runtest()
env/local/lib/python2.7/site-packages/_pytest/runner.py:98:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <DoctestItem 'unicode_helper.fix_bad_unicode'>
def runtest(self):
_check_all_skipped(self.dtest)
> self.runner.run(self.dtest)
env/local/lib/python2.7/site-packages/_pytest/doctest.py:98:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <doctest.DebugRunner instance at 0x7fe34f540710>
test = <DocTest unicode_helper.fix_bad_unicode from /tmp/test/unicode_helper.py:4 (1 example)>
compileflags = None, out = None, clear_globs = True
def run(self, test, compileflags=None, out=None, clear_globs=True):
> r = DocTestRunner.run(self, test, compileflags, out, False)
/usr/lib/python2.7/doctest.py:1799:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <doctest.DebugRunner instance at 0x7fe34f540710>
test = <DocTest unicode_helper.fix_bad_unicode from /tmp/test/unicode_helper.py:4 (1 example)>
compileflags = 131072
out = <bound method EncodedFile.write of <_pytest.capture.EncodedFile object at 0x7fe34f591e90>>
clear_globs = False
def run(self, test, compileflags=None, out=None, clear_globs=True):
"""
Run the examples in `test`, and display the results using the
writer function `out`.
The examples are run in the namespace `test.globs`. If
`clear_globs` is true (the default), then this namespace will
be cleared after the test runs, to help with garbage
collection. If you would like to examine the namespace after
the test completes, then use `clear_globs=False`.
`compileflags` gives the set of flags that should be used by
the Python compiler when running the examples. If not
specified, then it will default to the set of future-import
flags that apply to `globs`.
The output of each example is checked using
`DocTestRunner.check_output`, and the results are formatted by
the `DocTestRunner.report_*` methods.
"""
self.test = test
if compileflags is None:
compileflags = _extract_future_flags(test.globs)
save_stdout = sys.stdout
if out is None:
out = save_stdout.write
sys.stdout = self._fakeout
# Patch pdb.set_trace to restore sys.stdout during interactive
# debugging (so it's not still redirected to self._fakeout).
# Note that the interactive output will go to *our*
# save_stdout, even if that's not the real sys.stdout; this
# allows us to write test cases for the set_trace behavior.
save_set_trace = pdb.set_trace
self.debugger = _OutputRedirectingPdb(save_stdout)
self.debugger.reset()
pdb.set_trace = self.debugger.set_trace
# Patch linecache.getlines, so we can see the example's source
# when we're inside the debugger.
self.save_linecache_getlines = linecache.getlines
linecache.getlines = self.__patched_linecache_getlines
# Make sure sys.displayhook just prints the value to stdout
save_displayhook = sys.displayhook
sys.displayhook = sys.__displayhook__
try:
> return self.__run(test, compileflags, out)
/usr/lib/python2.7/doctest.py:1454:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <doctest.DebugRunner instance at 0x7fe34f540710>
test = <DocTest unicode_helper.fix_bad_unicode from /tmp/test/unicode_helper.py:4 (1 example)>
compileflags = 131072
out = <bound method EncodedFile.write of <_pytest.capture.EncodedFile object at 0x7fe34f591e90>>
def __run(self, test, compileflags, out):
"""
Run the examples in `test`. Write the outcome of each example
with one of the `DocTestRunner.report_*` methods, using the
writer function `out`. `compileflags` is the set of compiler
flags that should be used to execute examples. Return a tuple
`(f, t)`, where `t` is the number of examples tried, and `f`
is the number of examples that failed. The examples are run
in the namespace `test.globs`.
"""
# Keep track of the number of failures and tries.
failures = tries = 0
# Save the option flags (since option directives can be used
# to modify them).
original_optionflags = self.optionflags
SUCCESS, FAILURE, BOOM = range(3) # `outcome` state
check = self._checker.check_output
# Process each example.
for examplenum, example in enumerate(test.examples):
# If REPORT_ONLY_FIRST_FAILURE is set, then suppress
# reporting after the first failure.
quiet = (self.optionflags & REPORT_ONLY_FIRST_FAILURE and
failures > 0)
# Merge in the example's options.
self.optionflags = original_optionflags
if example.options:
for (optionflag, val) in example.options.items():
if val:
self.optionflags |= optionflag
else:
self.optionflags &= ~optionflag
# If 'SKIP' is set, then skip this example.
if self.optionflags & SKIP:
continue
# Record that we started this example.
tries += 1
if not quiet:
self.report_start(out, test, example)
# Use a special filename for compile(), so we can retrieve
# the source code during interactive debugging (see
# __patched_linecache_getlines).
filename = '<doctest %s[%d]>' % (test.name, examplenum)
# Run the example in the given context (globs), and record
# any exception that gets raised. (But don't intercept
# keyboard interrupts.)
try:
# Don't blink! This is where the user's code gets run.
exec compile(example.source, filename, "single",
compileflags, 1) in test.globs
self.debugger.set_continue() # ==== Example Finished ====
exception = None
except KeyboardInterrupt:
raise
except:
exception = sys.exc_info()
self.debugger.set_continue() # ==== Example Finished ====
> got = self._fakeout.getvalue() # the actual output
/usr/lib/python2.7/doctest.py:1324:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_pytest.doctest.UnicodeSpoof instance at 0x7fe34f540908>
def getvalue(self):
result = _SpoofOut.getvalue(self)
if encoding:
> result = result.decode(encoding)
env/local/lib/python2.7/site-packages/_pytest/doctest.py:350:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
input = '\xfanico\n', errors = 'strict'
def decode(input, errors='strict'):
> return codecs.utf_8_decode(input, errors, True)
E UnicodeEncodeError: 'ascii' codec can't encode character u'\xfa' in position 0: ordinal not in range(128)
env/lib/python2.7/encodings/utf_8.py:16: UnicodeEncodeError
=========================== 1 failed in 0.10 seconds ===========================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment