##// END OF EJS Templates
Merge pull request #1089 from mdboom/qtconsole-carriage-return...
Merge pull request #1089 from mdboom/qtconsole-carriage-return Support carriage return ('\r') and beep ('\b') characters in the qtconsole, providing text-mode 'scroll bars' and terminal bell in the console. It extends AnsiCodeProcessor to understand the '\r' character and move the cursor back to the start of the line. It also understands the '\b' character and calls QTApplication::beep(). Neither are strictly speaking ANSI code sequences, of course, but they seem related enough and was simple enough to do it this way. Closes #629.

File last commit:

r5390:c82649ea
r5641:21c436b6 merge
Show More
_paramtestpy3.py
71 lines | 2.3 KiB | text/x-python | PythonLexer
Fernando Perez
Added test support for better parametric tests and nose fixes....
r2367 """Implementation of the parametric test support for Python 3.x.
Thanks for the py3 version to Robert Collins, from the Testing in Python
mailing list.
"""
Brian Granger
Work to address the review comments on Fernando's branch....
r2498
#-----------------------------------------------------------------------------
Matthias BUSSONNIER
update copyright to 2011/20xx-2011...
r5390 # Copyright (C) 2009-2011 The IPython Development Team
Brian Granger
Work to address the review comments on Fernando's branch....
r2498 #
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
Fernando Perez
Added test support for better parametric tests and nose fixes....
r2367 #-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
import unittest
from unittest import TestSuite
#-----------------------------------------------------------------------------
# Classes and functions
#-----------------------------------------------------------------------------
def isgenerator(func):
return hasattr(func,'_generator')
class IterCallableSuite(TestSuite):
def __init__(self, iterator, adapter):
self._iter = iterator
self._adapter = adapter
def __iter__(self):
yield self._adapter(self._iter.__next__)
class ParametricTestCase(unittest.TestCase):
"""Write parametric tests in normal unittest testcase form.
Limitations: the last iteration misses printing out a newline when
running in verbose mode.
"""
def run(self, result=None):
testMethod = getattr(self, self._testMethodName)
# For normal tests, we just call the base class and return that
if isgenerator(testMethod):
def adapter(next_test):
Thomas Kluyver
Fix almost all IPython.core tests for Python 3.
r4896 ftc = unittest.FunctionTestCase(next_test,
self.setUp,
self.tearDown)
self._nose_case = ftc # Nose 1.0 rejects the test without this
return ftc
Fernando Perez
Added test support for better parametric tests and nose fixes....
r2367
return IterCallableSuite(testMethod(),adapter).run(result)
else:
return super(ParametricTestCase, self).run(result)
def parametric(func):
"""Decorator to make a simple function into a normal test via
unittest."""
# Hack, until I figure out how to write isgenerator() for python3!!
func._generator = True
class Tester(ParametricTestCase):
test = staticmethod(func)
Tester.__name__ = func.__name__
return Tester