From: Colin Watson <cjwatson@debian.org>
Date: Mon, 8 Jul 2024 23:11:42 +0100
Subject: Fix doctests

The doctests weren't being run and had bitrotted.  Make them work again.

Forwarded: https://github.com/ionelmc/python-tblib/pull/79/commits/d3b125f1b12af95c2d9f0e6a00ab05f3558444be
Last-Update: 2025-01-17
---
 README.rst | 32 ++++++++++++++++++++------------
 tox.ini    |  2 +-
 2 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/README.rst b/README.rst
index 1ed2db9..278a575 100644
--- a/README.rst
+++ b/README.rst
@@ -144,7 +144,7 @@ Raising
 
 ::
 
-    >>> from six import reraise
+    >>> from tblib.decorators import reraise
     >>> reraise(*pickle.loads(s1))
     Traceback (most recent call last):
       ...
@@ -431,22 +431,26 @@ json.JSONDecoder::
     {'tb_frame': {'f_code': {'co_filename': '<doctest README.rst[...]>',
                              'co_name': '<module>'},
                   'f_globals': {'__name__': '__main__'},
-                  'f_lineno': 5},
+                  'f_lineno': 5,
+                  'f_locals': {}},
      'tb_lineno': 2,
      'tb_next': {'tb_frame': {'f_code': {'co_filename': ...,
                                          'co_name': 'inner_2'},
                               'f_globals': {'__name__': '__main__'},
-                              'f_lineno': 2},
+                              'f_lineno': 2,
+                              'f_locals': {}},
                  'tb_lineno': 2,
                  'tb_next': {'tb_frame': {'f_code': {'co_filename': ...,
                                                      'co_name': 'inner_1'},
                                           'f_globals': {'__name__': '__main__'},
-                                          'f_lineno': 2},
+                                          'f_lineno': 2,
+                                          'f_locals': {}},
                              'tb_lineno': 2,
                              'tb_next': {'tb_frame': {'f_code': {'co_filename': ...,
                                                                  'co_name': 'inner_0'},
                                                       'f_globals': {'__name__': '__main__'},
-                                                      'f_lineno': 2},
+                                                      'f_lineno': 2,
+                                                      'f_locals': {}},
                                          'tb_lineno': 2,
                                          'tb_next': None}}}}
 
@@ -501,7 +505,7 @@ tblib.Traceback.from_string
       File "...examples.py", line 10, in func_c
         func_d()
       File "...examples.py", line 14, in func_d
-        raise Exception("Guessing time !")
+        raise Exception('Guessing time !')
     Exception: fail
 
 
@@ -532,7 +536,7 @@ If you use the ``strict=False`` option then parsing is a bit more lax::
       File "...examples.py", line 10, in func_c
         func_d()
       File "...examples.py", line 14, in func_d
-        raise Exception("Guessing time !")
+        raise Exception('Guessing time !')
     Exception: fail
 
 tblib.decorators.return_error
@@ -605,6 +609,8 @@ Not very useful is it? Let's sort this out::
         i.reraise()
       File "...tblib...decorators.py", line ..., in reraise
         reraise(self.exc_type, self.exc_value, self.traceback)
+      File "...tblib...decorators.py", line ..., in reraise
+        raise value.with_traceback(tb)
       File "...tblib...decorators.py", line ..., in return_exceptions_wrapper
         return func(*args, **kwargs)
       File "...tblib...decorators.py", line ..., in apply_with_return_error
@@ -616,7 +622,7 @@ Not very useful is it? Let's sort this out::
       File "...examples.py", line 10, in func_c
         func_d()
       File "...examples.py", line 14, in func_d
-        raise Exception("Guessing time !")
+        raise Exception('Guessing time !')
     Exception: Guessing time !
     <BLANKLINE>
     >>> pool.terminate()
@@ -658,11 +664,13 @@ What if we have a local call stack ?
         local_0()
       File "<doctest README.rst[...]>", line 6, in local_0
         i.reraise()
-      File "...tblib...decorators.py", line 20, in reraise
+      File "...tblib...decorators.py", line ..., in reraise
         reraise(self.exc_type, self.exc_value, self.traceback)
-      File "...tblib...decorators.py", line 27, in return_exceptions_wrapper
+      File "...tblib...decorators.py", line ..., in reraise
+        raise value.with_traceback(tb)
+      File "...tblib...decorators.py", line ..., in return_exceptions_wrapper
         return func(*args, **kwargs)
-      File "...tblib...decorators.py", line 47, in apply_with_return_error
+      File "...tblib...decorators.py", line ..., in apply_with_return_error
         return args[0](*args[1:])
       File "...tests...examples.py", line 2, in func_a
         func_b()
@@ -671,7 +679,7 @@ What if we have a local call stack ?
       File "...tests...examples.py", line 10, in func_c
         func_d()
       File "...tests...examples.py", line 14, in func_d
-        raise Exception("Guessing time !")
+        raise Exception('Guessing time !')
     Exception: Guessing time !
     <BLANKLINE>
 
diff --git a/tox.ini b/tox.ini
index 92154c0..a5872e4 100644
--- a/tox.ini
+++ b/tox.ini
@@ -40,7 +40,7 @@ deps =
     pytest-cov
     pytest-benchmark
 commands =
-    {posargs:pytest --cov --cov-report=term-missing --cov-report=xml -vv tests}
+    {posargs:pytest --cov --cov-report=term-missing --cov-report=xml -vv tests README.rst}
 
 [testenv:check]
 deps =
