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