From 7617110e9f3cf8b97991ce3727631f8ed800a571 2021-11-03 19:42:54 From: Nikita Kniazev Date: 2021-11-03 19:42:54 Subject: [PATCH] Add builtins._ doctest Defining builtins._ should not break anything outside the doctest while also should be working as expected inside the doctest. --- diff --git a/IPython/testing/plugin/test_ipdoctest.py b/IPython/testing/plugin/test_ipdoctest.py index d8f5991..2686172 100644 --- a/IPython/testing/plugin/test_ipdoctest.py +++ b/IPython/testing/plugin/test_ipdoctest.py @@ -74,3 +74,19 @@ def doctest_multiline3(): In [15]: h(0) Out[15]: -1 """ + + +def doctest_builtin_underscore(): + """Defining builtins._ should not break anything outside the doctest + while also should be working as expected inside the doctest. + + In [1]: import builtins + + In [2]: builtins._ = 42 + + In [3]: builtins._ + Out[3]: 42 + + In [4]: _ + Out[4]: 42 + """