diff options
author | ChangBo Guo(gcb) <eric.guo@easystack.cn> | 2015-12-30 15:58:00 +0800 |
---|---|---|
committer | Steve Martinelli <stevemar@ca.ibm.com> | 2016-02-11 01:55:34 -0500 |
commit | 12a544a0912d33519465c51c30545d3a7a800376 (patch) | |
tree | 22f17ad59aab0208ed26acabdffbf17a945a7f88 /cliff/tests/test_app.py | |
parent | 87075d698e855ba1f131fcbf8d42f73c14ccfcac (diff) | |
download | cliff-12a544a0912d33519465c51c30545d3a7a800376.tar.gz |
Drop Python 2.6 support
* Remove py2.6 from tox.ini
* Use itertools.compress(added in python 2.7) directly
* Use logging.NullHandler(added in python 2.7) directly
* Remove python 2.6 bug work around and related tests
Change-Id: Ie56a1590b9d4f0c544ebc5e7a4d40624e1ef4359
Diffstat (limited to 'cliff/tests/test_app.py')
-rw-r--r-- | cliff/tests/test_app.py | 142 |
1 files changed, 0 insertions, 142 deletions
diff --git a/cliff/tests/test_app.py b/cliff/tests/test_app.py index 19ff46b..718e1a2 100644 --- a/cliff/tests/test_app.py +++ b/cliff/tests/test_app.py @@ -4,9 +4,7 @@ try: from StringIO import StringIO except ImportError: from io import StringIO -import sys -import nose import mock from cliff.app import App @@ -274,146 +272,6 @@ def test_option_parser_abbrev_issue(): app.run(['--debug', 'mycommand', '--end', '123']) -def test_output_encoding_default(): - # The encoding should come from getdefaultlocale() because - # stdout has no encoding set. - if sys.version_info[:2] != (2, 6): - raise nose.SkipTest('only needed for python 2.6') - data = '\xc3\xa9' - u_data = data.decode('utf-8') - - class MyApp(App): - def __init__(self): - super(MyApp, self).__init__( - description='testing', - version='0.1', - command_manager=CommandManager('tests'), - ) - - stdout = StringIO() - - getdefaultlocale = mock.Mock(return_value=('ignored', 'utf-8')) - - with mock.patch('sys.stdout', stdout): - with mock.patch('locale.getdefaultlocale', getdefaultlocale): - app = MyApp() - app.stdout.write(u_data) - actual = stdout.getvalue() - assert data == actual - - -def test_output_encoding_cliff_default(): - # The encoding should come from cliff.App.DEFAULT_OUTPUT_ENCODING - # because the other values are missing or None - if sys.version_info[:2] != (2, 6): - raise nose.SkipTest('only needed for python 2.6') - data = '\xc3\xa9' - u_data = data.decode('utf-8') - - class MyApp(App): - def __init__(self): - super(MyApp, self).__init__( - description='testing', - version='0.1', - command_manager=CommandManager('tests'), - ) - - stdout = StringIO() - getdefaultlocale = mock.Mock(return_value=('ignored', None)) - - with mock.patch('sys.stdout', stdout): - with mock.patch('locale.getdefaultlocale', getdefaultlocale): - app = MyApp() - app.stdout.write(u_data) - actual = stdout.getvalue() - assert data == actual - - -def test_output_encoding_sys(): - # The encoding should come from sys.stdout because it is set - # there. - if sys.version_info[:2] != (2, 6): - raise nose.SkipTest('only needed for python 2.6') - data = '\xc3\xa9' - u_data = data.decode('utf-8') - - class MyApp(App): - def __init__(self): - super(MyApp, self).__init__( - description='testing', - version='0.1', - command_manager=CommandManager('tests'), - ) - - stdout = StringIO() - stdout.encoding = 'utf-8' - getdefaultlocale = mock.Mock(return_value=('ignored', 'utf-16')) - - with mock.patch('sys.stdout', stdout): - with mock.patch('locale.getdefaultlocale', getdefaultlocale): - app = MyApp() - app.stdout.write(u_data) - actual = stdout.getvalue() - assert data == actual - - -def test_error_encoding_default(): - # The encoding should come from getdefaultlocale() because - # stdout has no encoding set. - if sys.version_info[:2] != (2, 6): - raise nose.SkipTest('only needed for python 2.6') - data = '\xc3\xa9' - u_data = data.decode('utf-8') - - class MyApp(App): - def __init__(self): - super(MyApp, self).__init__( - description='testing', - version='0.1', - command_manager=CommandManager('tests'), - ) - - stderr = StringIO() - getdefaultlocale = mock.Mock(return_value=('ignored', 'utf-8')) - - with mock.patch('sys.stderr', stderr): - with mock.patch('locale.getdefaultlocale', getdefaultlocale): - app = MyApp() - app.stderr.write(u_data) - actual = stderr.getvalue() - assert data == actual - - -def test_error_encoding_sys(): - # The encoding should come from sys.stdout (not sys.stderr) - # because it is set there. - if sys.version_info[:2] != (2, 6): - raise nose.SkipTest('only needed for python 2.6') - data = '\xc3\xa9' - u_data = data.decode('utf-8') - - class MyApp(App): - def __init__(self): - super(MyApp, self).__init__( - description='testing', - version='0.1', - command_manager=CommandManager('tests'), - ) - - stdout = StringIO() - stdout.encoding = 'utf-8' - stderr = StringIO() - getdefaultlocale = mock.Mock(return_value=('ignored', 'utf-16')) - - with mock.patch('sys.stdout', stdout): - with mock.patch('sys.stderr', stderr): - with mock.patch('locale.getdefaultlocale', getdefaultlocale): - app = MyApp() - app.stderr.write(u_data) - actual = stderr.getvalue() - assert data == actual - - def _test_help(deferred_help): app, _ = make_app(deferred_help=deferred_help) with mock.patch.object(app, 'initialize_app') as init: |