repr_traceback to work with unicode errors
The tests are passing. I actually have mixed felling about the way I did it. The other possible way is to use something like:
After some thought I realized that we only need to check if the exception was a "maximum recursion depth" exception, we don't need to try to come up with a generic solution to convert a solution to string first.
With that in mind how about:
# code.py if sys.version_info[:2] >= (3, 5): # RecursionError introduced in 3.5 def is_recursion_error(exception): return isinstance(exception, RecursionError) else: def is_recursion_error(exception): if not isinstance(exception, RuntimeError): return False try: return "maximum recursion depth exceeded" in str(exception) except UnicodeDecodeError: return False class FormattedExcinfo(object): ... def repr_traceback(self, excinfo): traceback = excinfo.traceback if self.tbfilter: traceback = traceback.filter() recursionindex = None if is_recursion_error(excinfo.value): recursionindex = traceback.recursionindex() ...
What do you think?
2.9.2 ===== **Bug Fixes** * fix `#510`_: skip tests where one parameterize dimension was empty thanks Alex Stapleton for the Report and `@RonnyPfannschmidt`_ for the PR * Fix Xfail does not work with condition keyword argument. Thanks `@astraw38`_ for reporting the issue (`#1496`_) and `@tomviner`_ for PR the (`#1524`_). * Fix win32 path issue when puttinging custom config file with absolute path in ``pytest.main("-c your_absolute_path")``. * Fix maximum recursion depth detection when raised error class is not aware of unicode/encoded bytes. Thanks `@prusse-martin`_ for the PR (`#1506`_). * Fix ``pytest.mark.skip`` mark when used in strict mode. Thanks `@pquentin`_ for the PR and `@RonnyPfannschmidt`_ for showing how to fix the bug. * Minor improvements and fixes to the documentation. Thanks `@omarkohl`_ for the PR. * Fix ``--fixtures`` to show all fixture definitions as opposed to just one per fixture name. Thanks to `@hackebrot`_ for the PR. .. _#510: pytest-dev/pytest#510 .. _#1506: pytest-dev/pytest#1506 .. _#1496: https://github.com/pytest-dev/pytest/issue/1496 .. _#1524: https://github.com/pytest-dev/pytest/issue/1524 .. _@prusse-martin: https://github.com/prusse-martin .. _@astraw38: https://github.com/astraw38