|
|
0c393bd |
From 78cf4e41560ba35e1fcc24150aaf6fc3d0cac203 Mon Sep 17 00:00:00 2001
|
|
|
0c393bd |
From: Lumir Balhar <lbalhar@redhat.com>
|
|
|
0c393bd |
Date: Tue, 5 May 2020 16:38:43 +0200
|
|
|
0c393bd |
Subject: [PATCH] Remove tests not compatible with Python 3.9.0a6
|
|
|
0c393bd |
|
|
|
0c393bd |
---
|
|
|
0c393bd |
IPython/core/tests/test_async_helpers.py | 7 +-
|
|
|
0c393bd |
IPython/core/tests/test_debugger.py | 98 ++----------------------
|
|
|
0c393bd |
IPython/core/tests/test_oinspect.py | 44 +++--------
|
|
|
0c393bd |
IPython/core/tests/test_ultratb.py | 33 ++++----
|
|
|
0c393bd |
4 files changed, 29 insertions(+), 153 deletions(-)
|
|
|
0c393bd |
|
|
|
0c393bd |
diff --git a/IPython/core/tests/test_async_helpers.py b/IPython/core/tests/test_async_helpers.py
|
|
|
0c393bd |
index 86a516c..a7c7963 100644
|
|
|
0c393bd |
--- a/IPython/core/tests/test_async_helpers.py
|
|
|
0c393bd |
+++ b/IPython/core/tests/test_async_helpers.py
|
|
|
0c393bd |
@@ -1,5 +1,5 @@
|
|
|
0c393bd |
"""
|
|
|
0c393bd |
-Test for async helpers.
|
|
|
0c393bd |
+Test for async helpers.
|
|
|
0c393bd |
|
|
|
0c393bd |
Should only trigger on python 3.5+ or will have syntax errors.
|
|
|
0c393bd |
"""
|
|
|
0c393bd |
@@ -275,11 +275,6 @@ class AsyncTest(TestCase):
|
|
|
0c393bd |
await sleep(0.1)
|
|
|
0c393bd |
"""
|
|
|
0c393bd |
)
|
|
|
0c393bd |
-
|
|
|
0c393bd |
- def test_memory_error(self):
|
|
|
0c393bd |
- with self.assertRaises(MemoryError):
|
|
|
0c393bd |
- iprc("(" * 200 + ")" * 200)
|
|
|
0c393bd |
-
|
|
|
0c393bd |
@skip_without('curio')
|
|
|
0c393bd |
def test_autoawait_curio(self):
|
|
|
0c393bd |
iprc("%autoawait curio")
|
|
|
0c393bd |
diff --git a/IPython/core/tests/test_debugger.py b/IPython/core/tests/test_debugger.py
|
|
|
0c393bd |
index 7f3720a..338fe12 100644
|
|
|
0c393bd |
--- a/IPython/core/tests/test_debugger.py
|
|
|
0c393bd |
+++ b/IPython/core/tests/test_debugger.py
|
|
|
0c393bd |
@@ -60,7 +60,7 @@ def test_longer_repr():
|
|
|
0c393bd |
from reprlib import repr as trepr # Py 3
|
|
|
0c393bd |
except ImportError:
|
|
|
0c393bd |
from repr import repr as trepr # Py 2
|
|
|
0c393bd |
-
|
|
|
0c393bd |
+
|
|
|
0c393bd |
a = '1234567890'* 7
|
|
|
0c393bd |
ar = "'1234567890123456789012345678901234567890123456789012345678901234567890'"
|
|
|
0c393bd |
a_trunc = "'123456789012...8901234567890'"
|
|
|
0c393bd |
@@ -72,97 +72,9 @@ def test_longer_repr():
|
|
|
0c393bd |
debugger.Tracer()
|
|
|
0c393bd |
nt.assert_equal(trepr(a), ar)
|
|
|
0c393bd |
|
|
|
0c393bd |
-def test_ipdb_magics():
|
|
|
0c393bd |
- '''Test calling some IPython magics from ipdb.
|
|
|
0c393bd |
-
|
|
|
0c393bd |
- First, set up some test functions and classes which we can inspect.
|
|
|
0c393bd |
-
|
|
|
0c393bd |
- >>> class ExampleClass(object):
|
|
|
0c393bd |
- ... """Docstring for ExampleClass."""
|
|
|
0c393bd |
- ... def __init__(self):
|
|
|
0c393bd |
- ... """Docstring for ExampleClass.__init__"""
|
|
|
0c393bd |
- ... pass
|
|
|
0c393bd |
- ... def __str__(self):
|
|
|
0c393bd |
- ... return "ExampleClass()"
|
|
|
0c393bd |
-
|
|
|
0c393bd |
- >>> def example_function(x, y, z="hello"):
|
|
|
0c393bd |
- ... """Docstring for example_function."""
|
|
|
0c393bd |
- ... pass
|
|
|
0c393bd |
-
|
|
|
0c393bd |
- >>> old_trace = sys.gettrace()
|
|
|
0c393bd |
-
|
|
|
0c393bd |
- Create a function which triggers ipdb.
|
|
|
0c393bd |
-
|
|
|
0c393bd |
- >>> def trigger_ipdb():
|
|
|
0c393bd |
- ... a = ExampleClass()
|
|
|
0c393bd |
- ... debugger.Pdb().set_trace()
|
|
|
0c393bd |
-
|
|
|
0c393bd |
- >>> with PdbTestInput([
|
|
|
0c393bd |
- ... 'pdef example_function',
|
|
|
0c393bd |
- ... 'pdoc ExampleClass',
|
|
|
0c393bd |
- ... 'up',
|
|
|
0c393bd |
- ... 'down',
|
|
|
0c393bd |
- ... 'list',
|
|
|
0c393bd |
- ... 'pinfo a',
|
|
|
0c393bd |
- ... 'll',
|
|
|
0c393bd |
- ... 'continue',
|
|
|
0c393bd |
- ... ]):
|
|
|
0c393bd |
- ... trigger_ipdb()
|
|
|
0c393bd |
- --Return--
|
|
|
0c393bd |
- None
|
|
|
0c393bd |
- > <doctest ...>(3)trigger_ipdb()
|
|
|
0c393bd |
- 1 def trigger_ipdb():
|
|
|
0c393bd |
- 2 a = ExampleClass()
|
|
|
0c393bd |
- ----> 3 debugger.Pdb().set_trace()
|
|
|
0c393bd |
- <BLANKLINE>
|
|
|
0c393bd |
- ipdb> pdef example_function
|
|
|
0c393bd |
- example_function(x, y, z='hello')
|
|
|
0c393bd |
- ipdb> pdoc ExampleClass
|
|
|
0c393bd |
- Class docstring:
|
|
|
0c393bd |
- Docstring for ExampleClass.
|
|
|
0c393bd |
- Init docstring:
|
|
|
0c393bd |
- Docstring for ExampleClass.__init__
|
|
|
0c393bd |
- ipdb> up
|
|
|
0c393bd |
- > <doctest ...>(11)<module>()
|
|
|
0c393bd |
- 7 'pinfo a',
|
|
|
0c393bd |
- 8 'll',
|
|
|
0c393bd |
- 9 'continue',
|
|
|
0c393bd |
- 10 ]):
|
|
|
0c393bd |
- ---> 11 trigger_ipdb()
|
|
|
0c393bd |
- <BLANKLINE>
|
|
|
0c393bd |
- ipdb> down
|
|
|
0c393bd |
- None
|
|
|
0c393bd |
- > <doctest ...>(3)trigger_ipdb()
|
|
|
0c393bd |
- 1 def trigger_ipdb():
|
|
|
0c393bd |
- 2 a = ExampleClass()
|
|
|
0c393bd |
- ----> 3 debugger.Pdb().set_trace()
|
|
|
0c393bd |
- <BLANKLINE>
|
|
|
0c393bd |
- ipdb> list
|
|
|
0c393bd |
- 1 def trigger_ipdb():
|
|
|
0c393bd |
- 2 a = ExampleClass()
|
|
|
0c393bd |
- ----> 3 debugger.Pdb().set_trace()
|
|
|
0c393bd |
- <BLANKLINE>
|
|
|
0c393bd |
- ipdb> pinfo a
|
|
|
0c393bd |
- Type: ExampleClass
|
|
|
0c393bd |
- String form: ExampleClass()
|
|
|
0c393bd |
- Namespace: Local...
|
|
|
0c393bd |
- Docstring: Docstring for ExampleClass.
|
|
|
0c393bd |
- Init docstring: Docstring for ExampleClass.__init__
|
|
|
0c393bd |
- ipdb> ll
|
|
|
0c393bd |
- 1 def trigger_ipdb():
|
|
|
0c393bd |
- 2 a = ExampleClass()
|
|
|
0c393bd |
- ----> 3 debugger.Pdb().set_trace()
|
|
|
0c393bd |
- <BLANKLINE>
|
|
|
0c393bd |
- ipdb> continue
|
|
|
0c393bd |
-
|
|
|
0c393bd |
- Restore previous trace function, e.g. for coverage.py
|
|
|
0c393bd |
-
|
|
|
0c393bd |
- >>> sys.settrace(old_trace)
|
|
|
0c393bd |
- '''
|
|
|
0c393bd |
-
|
|
|
0c393bd |
def test_ipdb_magics2():
|
|
|
0c393bd |
'''Test ipdb with a very short function.
|
|
|
0c393bd |
-
|
|
|
0c393bd |
+
|
|
|
0c393bd |
>>> old_trace = sys.gettrace()
|
|
|
0c393bd |
|
|
|
0c393bd |
>>> def bar():
|
|
|
0c393bd |
@@ -179,9 +91,9 @@ def test_ipdb_magics2():
|
|
|
0c393bd |
----> 2 pass
|
|
|
0c393bd |
<BLANKLINE>
|
|
|
0c393bd |
ipdb> continue
|
|
|
0c393bd |
-
|
|
|
0c393bd |
- Restore previous trace function, e.g. for coverage.py
|
|
|
0c393bd |
-
|
|
|
0c393bd |
+
|
|
|
0c393bd |
+ Restore previous trace function, e.g. for coverage.py
|
|
|
0c393bd |
+
|
|
|
0c393bd |
>>> sys.settrace(old_trace)
|
|
|
0c393bd |
'''
|
|
|
0c393bd |
|
|
|
0c393bd |
diff --git a/IPython/core/tests/test_oinspect.py b/IPython/core/tests/test_oinspect.py
|
|
|
0c393bd |
index 8bdcfad..eba51fd 100644
|
|
|
0c393bd |
--- a/IPython/core/tests/test_oinspect.py
|
|
|
0c393bd |
+++ b/IPython/core/tests/test_oinspect.py
|
|
|
0c393bd |
@@ -74,7 +74,7 @@ def test_find_file_decorated1():
|
|
|
0c393bd |
@noop1
|
|
|
0c393bd |
def f(x):
|
|
|
0c393bd |
"My docstring"
|
|
|
0c393bd |
-
|
|
|
0c393bd |
+
|
|
|
0c393bd |
match_pyfiles(oinspect.find_file(f), os.path.abspath(__file__))
|
|
|
0c393bd |
nt.assert_equal(f.__doc__, "My docstring")
|
|
|
0c393bd |
|
|
|
0c393bd |
@@ -90,10 +90,10 @@ def test_find_file_decorated2():
|
|
|
0c393bd |
@noop2
|
|
|
0c393bd |
def f(x):
|
|
|
0c393bd |
"My docstring 2"
|
|
|
0c393bd |
-
|
|
|
0c393bd |
+
|
|
|
0c393bd |
match_pyfiles(oinspect.find_file(f), os.path.abspath(__file__))
|
|
|
0c393bd |
nt.assert_equal(f.__doc__, "My docstring 2")
|
|
|
0c393bd |
-
|
|
|
0c393bd |
+
|
|
|
0c393bd |
|
|
|
0c393bd |
def test_find_file_magic():
|
|
|
0c393bd |
run = ip.find_line_magic('run')
|
|
|
0c393bd |
@@ -234,43 +234,19 @@ def test_definition_kwonlyargs():
|
|
|
0c393bd |
i = inspector.info(f_kwarg, oname='f_kwarg') # analysis:ignore
|
|
|
0c393bd |
nt.assert_equal(i['definition'], "f_kwarg(pos, *, kwonly)")
|
|
|
0c393bd |
|
|
|
0c393bd |
-def test_getdoc():
|
|
|
0c393bd |
- class A(object):
|
|
|
0c393bd |
- """standard docstring"""
|
|
|
0c393bd |
- pass
|
|
|
0c393bd |
-
|
|
|
0c393bd |
- class B(object):
|
|
|
0c393bd |
- """standard docstring"""
|
|
|
0c393bd |
- def getdoc(self):
|
|
|
0c393bd |
- return "custom docstring"
|
|
|
0c393bd |
-
|
|
|
0c393bd |
- class C(object):
|
|
|
0c393bd |
- """standard docstring"""
|
|
|
0c393bd |
- def getdoc(self):
|
|
|
0c393bd |
- return None
|
|
|
0c393bd |
-
|
|
|
0c393bd |
- a = A()
|
|
|
0c393bd |
- b = B()
|
|
|
0c393bd |
- c = C()
|
|
|
0c393bd |
-
|
|
|
0c393bd |
- nt.assert_equal(oinspect.getdoc(a), "standard docstring")
|
|
|
0c393bd |
- nt.assert_equal(oinspect.getdoc(b), "custom docstring")
|
|
|
0c393bd |
- nt.assert_equal(oinspect.getdoc(c), "standard docstring")
|
|
|
0c393bd |
-
|
|
|
0c393bd |
-
|
|
|
0c393bd |
def test_empty_property_has_no_source():
|
|
|
0c393bd |
i = inspector.info(property(), detail_level=1)
|
|
|
0c393bd |
nt.assert_is(i['source'], None)
|
|
|
0c393bd |
|
|
|
0c393bd |
|
|
|
0c393bd |
def test_property_sources():
|
|
|
0c393bd |
- import posixpath
|
|
|
0c393bd |
+ import posixpath
|
|
|
0c393bd |
# A simple adder whose source and signature stays
|
|
|
0c393bd |
# the same across Python distributions
|
|
|
0c393bd |
def simple_add(a, b):
|
|
|
0c393bd |
"Adds two numbers"
|
|
|
0c393bd |
return a + b
|
|
|
0c393bd |
-
|
|
|
0c393bd |
+
|
|
|
0c393bd |
class A(object):
|
|
|
0c393bd |
@property
|
|
|
0c393bd |
def foo(self):
|
|
|
0c393bd |
@@ -279,7 +255,7 @@ def test_property_sources():
|
|
|
0c393bd |
foo = foo.setter(lambda self, v: setattr(self, 'bar', v))
|
|
|
0c393bd |
|
|
|
0c393bd |
dname = property(posixpath.dirname)
|
|
|
0c393bd |
- adder = property(simple_add)
|
|
|
0c393bd |
+ adder = property(simple_add)
|
|
|
0c393bd |
|
|
|
0c393bd |
i = inspector.info(A.foo, detail_level=1)
|
|
|
0c393bd |
nt.assert_in('def foo(self):', i['source'])
|
|
|
0c393bd |
@@ -287,7 +263,7 @@ def test_property_sources():
|
|
|
0c393bd |
|
|
|
0c393bd |
i = inspector.info(A.dname, detail_level=1)
|
|
|
0c393bd |
nt.assert_in('def dirname(p)', i['source'])
|
|
|
0c393bd |
-
|
|
|
0c393bd |
+
|
|
|
0c393bd |
i = inspector.info(A.adder, detail_level=1)
|
|
|
0c393bd |
nt.assert_in('def simple_add(a, b)', i['source'])
|
|
|
0c393bd |
|
|
|
0c393bd |
@@ -359,11 +335,11 @@ def test_pinfo_docstring_if_detail_and_no_source():
|
|
|
0c393bd |
def bar(self):
|
|
|
0c393bd |
""" This is a docstring for Foo.bar """
|
|
|
0c393bd |
pass
|
|
|
0c393bd |
- '''
|
|
|
0c393bd |
-
|
|
|
0c393bd |
+ '''
|
|
|
0c393bd |
+
|
|
|
0c393bd |
ip.run_cell(obj_def)
|
|
|
0c393bd |
ip.run_cell('foo = Foo()')
|
|
|
0c393bd |
-
|
|
|
0c393bd |
+
|
|
|
0c393bd |
with AssertNotPrints("Source:"):
|
|
|
0c393bd |
with AssertPrints('Docstring:'):
|
|
|
0c393bd |
ip._inspect('pinfo', 'foo', detail_level=0)
|
|
|
0c393bd |
diff --git a/IPython/core/tests/test_ultratb.py b/IPython/core/tests/test_ultratb.py
|
|
|
0c393bd |
index 3ab0ce3..c7139ef 100644
|
|
|
0c393bd |
--- a/IPython/core/tests/test_ultratb.py
|
|
|
0c393bd |
+++ b/IPython/core/tests/test_ultratb.py
|
|
|
0c393bd |
@@ -57,24 +57,24 @@ def recursionlimit(frames):
|
|
|
0c393bd |
class ChangedPyFileTest(unittest.TestCase):
|
|
|
0c393bd |
def test_changing_py_file(self):
|
|
|
0c393bd |
"""Traceback produced if the line where the error occurred is missing?
|
|
|
0c393bd |
-
|
|
|
0c393bd |
+
|
|
|
0c393bd |
https://github.com/ipython/ipython/issues/1456
|
|
|
0c393bd |
"""
|
|
|
0c393bd |
with TemporaryDirectory() as td:
|
|
|
0c393bd |
fname = os.path.join(td, "foo.py")
|
|
|
0c393bd |
with open(fname, "w") as f:
|
|
|
0c393bd |
f.write(file_1)
|
|
|
0c393bd |
-
|
|
|
0c393bd |
+
|
|
|
0c393bd |
with prepended_to_syspath(td):
|
|
|
0c393bd |
ip.run_cell("import foo")
|
|
|
0c393bd |
-
|
|
|
0c393bd |
+
|
|
|
0c393bd |
with tt.AssertPrints("ZeroDivisionError"):
|
|
|
0c393bd |
ip.run_cell("foo.f()")
|
|
|
0c393bd |
-
|
|
|
0c393bd |
+
|
|
|
0c393bd |
# Make the file shorter, so the line of the error is missing.
|
|
|
0c393bd |
with open(fname, "w") as f:
|
|
|
0c393bd |
f.write(file_2)
|
|
|
0c393bd |
-
|
|
|
0c393bd |
+
|
|
|
0c393bd |
# For some reason, this was failing on the *second* call after
|
|
|
0c393bd |
# changing the file, so we call f() twice.
|
|
|
0c393bd |
with tt.AssertNotPrints("Internal Python error", channel='stderr'):
|
|
|
0c393bd |
@@ -98,27 +98,27 @@ class NonAsciiTest(unittest.TestCase):
|
|
|
0c393bd |
fname = os.path.join(td, u"fooé.py")
|
|
|
0c393bd |
with open(fname, "w") as f:
|
|
|
0c393bd |
f.write(file_1)
|
|
|
0c393bd |
-
|
|
|
0c393bd |
+
|
|
|
0c393bd |
with prepended_to_syspath(td):
|
|
|
0c393bd |
ip.run_cell("import foo")
|
|
|
0c393bd |
-
|
|
|
0c393bd |
+
|
|
|
0c393bd |
with tt.AssertPrints("ZeroDivisionError"):
|
|
|
0c393bd |
ip.run_cell("foo.f()")
|
|
|
0c393bd |
-
|
|
|
0c393bd |
+
|
|
|
0c393bd |
def test_iso8859_5(self):
|
|
|
0c393bd |
with TemporaryDirectory() as td:
|
|
|
0c393bd |
fname = os.path.join(td, 'dfghjkl.py')
|
|
|
0c393bd |
|
|
|
0c393bd |
with io.open(fname, 'w', encoding='iso-8859-5') as f:
|
|
|
0c393bd |
f.write(iso_8859_5_file)
|
|
|
0c393bd |
-
|
|
|
0c393bd |
+
|
|
|
0c393bd |
with prepended_to_syspath(td):
|
|
|
0c393bd |
ip.run_cell("from dfghjkl import fail")
|
|
|
0c393bd |
-
|
|
|
0c393bd |
+
|
|
|
0c393bd |
with tt.AssertPrints("ZeroDivisionError"):
|
|
|
0c393bd |
with tt.AssertPrints(u'дбИЖ', suppress=False):
|
|
|
0c393bd |
ip.run_cell('fail()')
|
|
|
0c393bd |
-
|
|
|
0c393bd |
+
|
|
|
0c393bd |
def test_nonascii_msg(self):
|
|
|
0c393bd |
cell = u"raise Exception('é')"
|
|
|
0c393bd |
expected = u"Exception('é')"
|
|
|
0c393bd |
@@ -173,12 +173,12 @@ class IndentationErrorTest(unittest.TestCase):
|
|
|
0c393bd |
with tt.AssertPrints("IndentationError"):
|
|
|
0c393bd |
with tt.AssertPrints("zoon()", suppress=False):
|
|
|
0c393bd |
ip.run_cell(indentationerror_file)
|
|
|
0c393bd |
-
|
|
|
0c393bd |
+
|
|
|
0c393bd |
with TemporaryDirectory() as td:
|
|
|
0c393bd |
fname = os.path.join(td, "foo.py")
|
|
|
0c393bd |
with open(fname, "w") as f:
|
|
|
0c393bd |
f.write(indentationerror_file)
|
|
|
0c393bd |
-
|
|
|
0c393bd |
+
|
|
|
0c393bd |
with tt.AssertPrints("IndentationError"):
|
|
|
0c393bd |
with tt.AssertPrints("zoon()", suppress=False):
|
|
|
0c393bd |
ip.magic('run %s' % fname)
|
|
|
0c393bd |
@@ -253,13 +253,6 @@ bar()
|
|
|
0c393bd |
ip.showsyntaxerror()
|
|
|
0c393bd |
|
|
|
0c393bd |
|
|
|
0c393bd |
-class MemoryErrorTest(unittest.TestCase):
|
|
|
0c393bd |
- def test_memoryerror(self):
|
|
|
0c393bd |
- memoryerror_code = "(" * 200 + ")" * 200
|
|
|
0c393bd |
- with tt.AssertPrints("MemoryError"):
|
|
|
0c393bd |
- ip.run_cell(memoryerror_code)
|
|
|
0c393bd |
-
|
|
|
0c393bd |
-
|
|
|
0c393bd |
class Python3ChainedExceptionsTest(unittest.TestCase):
|
|
|
0c393bd |
DIRECT_CAUSE_ERROR_CODE = """
|
|
|
0c393bd |
try:
|
|
|
0c393bd |
--
|
|
|
0c393bd |
2.26.2
|
|
|
0c393bd |
|