summaryrefslogtreecommitdiff
path: root/tests/test_cfg.py
diff options
context:
space:
mode:
authorCyril Roelandt <cyril.roelandt@enovance.com>2014-04-06 19:36:27 +0200
committerCyril Roelandt <cyril.roelandt@enovance.com>2014-04-25 11:15:26 +0200
commit0a66c272cba4aea5dd37d2da47c45d5fa46818dc (patch)
tree6f2778d157b78ce14da8076b93d3df6f959f991a /tests/test_cfg.py
parent78225a58835eeae1d05d99cc3e76e71a2e75dab3 (diff)
downloadoslo-config-0a66c272cba4aea5dd37d2da47c45d5fa46818dc.tar.gz
Fix test_version on Python 3.4
Since Python 3.4, argparse has been printing the version on stdout rather than on stderr as it used to. We should fix this now because: - this is an issue when packaging oslo-config in Debian Sid, which uses Python 3.4; - it will be needed when Openstack switches to 3.4 anyway. Change-Id: I6a84009acb8621d62465c4cd2573200a07b6b4ab
Diffstat (limited to 'tests/test_cfg.py')
-rw-r--r--tests/test_cfg.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/tests/test_cfg.py b/tests/test_cfg.py
index f1f576b..a4aaf42 100644
--- a/tests/test_cfg.py
+++ b/tests/test_cfg.py
@@ -479,9 +479,16 @@ class CliSpecialOptsTestCase(BaseTestCase):
self.assertTrue('--config-file' in sys.stdout.getvalue())
def test_version(self):
- self.useFixture(fixtures.MonkeyPatch('sys.stderr', moves.StringIO()))
+ # In Python 3.4+, argparse prints the version on stdout; before 3.4, it
+ # printed it on stderr.
+ if sys.version_info >= (3, 4):
+ stream_name = 'stdout'
+ else:
+ stream_name = 'stderr'
+ self.useFixture(fixtures.MonkeyPatch("sys.%s" % stream_name,
+ moves.StringIO()))
self.assertRaises(SystemExit, self.conf, ['--version'])
- self.assertTrue('1.0' in sys.stderr.getvalue())
+ self.assertTrue('1.0' in getattr(sys, stream_name).getvalue())
def test_config_file(self):
paths = self.create_tempfiles([('1', '[DEFAULT]'),