From 21bd93534e6056cdecdb66f27d8b3befa59850c7 2011-10-26 20:47:22 From: Thomas Kluyver Date: 2011-10-26 20:47:22 Subject: [PATCH] Add decorators to mark known failures on Python 3. --- diff --git a/IPython/core/oinspect.py b/IPython/core/oinspect.py index 80b9c2f..472611d 100644 --- a/IPython/core/oinspect.py +++ b/IPython/core/oinspect.py @@ -31,6 +31,7 @@ except ImportError: # IPython's own from IPython.core import page +from IPython.testing.skipdoctest import skip_doctest_py3 from IPython.utils import PyColorize from IPython.utils import io from IPython.utils import py3compat @@ -297,6 +298,8 @@ class Inspector: else: print >>io.stdout, header,self.format(output), + # In Python 3, all classes are new-style, so they all have __init__. + @skip_doctest_py3 def pdoc(self,obj,oname='',formatter = None): """Print the docstring for any object. diff --git a/IPython/extensions/tests/test_autoreload.py b/IPython/extensions/tests/test_autoreload.py index d4b4005..2227a06 100644 --- a/IPython/extensions/tests/test_autoreload.py +++ b/IPython/extensions/tests/test_autoreload.py @@ -11,6 +11,7 @@ import IPython.testing.tools as tt from IPython.extensions.autoreload import AutoreloadInterface from IPython.core.hooks import TryNext +from IPython.testing.decorators import knownfailureif #----------------------------------------------------------------------------- # Test fixture @@ -293,8 +294,12 @@ x = -99 self.shell.run_code("pass") # trigger reload nt.assert_equal(mod.x, -99) + # The autoreload extension needs to be updated for Python 3.2, as .pyc files + # are stored in a different location. See gh-846. + @knownfailureif(sys.version_info >= (3,2)) def test_smoketest_aimport(self): self._check_smoketest(use_aimport=True) + @knownfailureif(sys.version_info >= (3,2)) def test_smoketest_autoreload(self): self._check_smoketest(use_aimport=False) diff --git a/IPython/lib/tests/test_irunner.py b/IPython/lib/tests/test_irunner.py index 642938b..dcad7aa 100644 --- a/IPython/lib/tests/test_irunner.py +++ b/IPython/lib/tests/test_irunner.py @@ -13,6 +13,7 @@ import unittest # IPython imports from IPython.lib import irunner +from IPython.testing.decorators import known_failure_py3 # Testing code begins class RunnerTestCase(unittest.TestCase): @@ -56,6 +57,8 @@ class RunnerTestCase(unittest.TestCase): self.assert_(mismatch==0,'Number of mismatched lines: %s' % mismatch) + # irunner isn't working on Python 3 (due to pexpect) + @known_failure_py3 def testIPython(self): """Test the IPython runner.""" source = """ @@ -129,6 +132,7 @@ In [12]: exit runner = irunner.IPythonRunner(out=self.out) self._test_runner(runner,source,output) + @known_failure_py3 def testPython(self): """Test the Python runner.""" runner = irunner.PythonRunner(out=self.out) diff --git a/IPython/lib/tests/test_irunner_pylab_magic.py b/IPython/lib/tests/test_irunner_pylab_magic.py index eb3f352..1d3ef7b 100644 --- a/IPython/lib/tests/test_irunner_pylab_magic.py +++ b/IPython/lib/tests/test_irunner_pylab_magic.py @@ -22,6 +22,7 @@ class RunnerTestCase(unittest.TestCase): self.out = StringIO.StringIO() #self.out = sys.stdout + @decorators.known_failure_py3 def _test_runner(self,runner,source,output): """Test that a given runner's input/output match.""" @@ -82,6 +83,7 @@ Out\[6\]: True runner = irunner.IPythonRunner(out=self.out) self._test_runner(runner,source,output) + @decorators.known_failure_py3 @decorators.skipif_not_matplotlib def test_pylab_import_all_disabled(self): "Verify that plot is not available when pylab_import_all = False" diff --git a/IPython/testing/decorators.py b/IPython/testing/decorators.py index 8f46202..661a9f1 100644 --- a/IPython/testing/decorators.py +++ b/IPython/testing/decorators.py @@ -323,6 +323,9 @@ skipif_not_sympy = skip_without('sympy') skip_known_failure = knownfailureif(True,'This test is known to fail') +known_failure_py3 = knownfailureif(sys.version_info[0] >= 3, + 'This test is known to fail on Python 3.') + # A null 'decorator', useful to make more readable code that needs to pick # between different decorators based on OS or other conditions null_deco = lambda f: f diff --git a/IPython/testing/skipdoctest.py b/IPython/testing/skipdoctest.py index bcb7e0a..0c18914 100644 --- a/IPython/testing/skipdoctest.py +++ b/IPython/testing/skipdoctest.py @@ -4,6 +4,7 @@ The IPython.testing.decorators module triggers various extra imports, including numpy and sympy if they're present. Since this decorator is used in core parts of IPython, it's in a separate module so that running IPython doesn't trigger those imports.""" +import sys def skip_doctest(f): """Decorator - mark a function or method for skipping its doctest. @@ -13,3 +14,8 @@ def skip_doctest(f): etc.""" f.skip_doctest = True return f + +def skip_doctest_py3(f): + """Decorator - skip the doctest under Python 3.""" + f.skip_doctest = (sys.version_info[0] >= 3) + return f