summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk Mueller <dirk@dmllr.de>2013-02-22 16:11:12 +0100
committerDirk Mueller <dirk@dmllr.de>2013-03-15 17:38:04 +0100
commit31960f0a8584802852d97ec8ce27b5516b32d63b (patch)
tree4a3fe74b9d00f155c47c84019b945c293600f0c8
parent6c7fb0e46cd34b1f9b90d0de052c5fe01fc7b725 (diff)
downloadpython-glanceclient-31960f0a8584802852d97ec8ce27b5516b32d63b.tar.gz
Allow for prettytable 0.7.x as well
Relax requirements to >= 0.6, < 0.8, as 0.7.x seems to work as well. Added testcase to ensure this. Change-Id: I1a1a709e6053451b1256a0d78f8fe8562fb10e62
-rw-r--r--tests/test_utils.py43
-rw-r--r--tools/pip-requires2
2 files changed, 44 insertions, 1 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 3f275b8..279f5d6 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -15,6 +15,8 @@
import errno
import testtools
+import sys
+import StringIO
from glanceclient.common import utils
@@ -69,6 +71,47 @@ class TestUtils(testtools.TestCase):
self.assertEqual(u'ni\xf1o', ensure_unicode('ni\xc3\xb1o',
incoming='ascii'))
+ def test_prettytable(self):
+ class Struct:
+ def __init__(self, **entries):
+ self.__dict__.update(entries)
+
+ # test that the prettytable output is wellformatted (left-aligned)
+ columns = ['ID', 'Name']
+ val = ['Name1', 'another', 'veeeery long']
+ images = [Struct(**{'id': i ** 16, 'name': val[i]})
+ for i in range(len(val))]
+
+ saved_stdout = sys.stdout
+ try:
+ sys.stdout = output_list = StringIO.StringIO()
+ utils.print_list(images, columns)
+
+ sys.stdout = output_dict = StringIO.StringIO()
+ utils.print_dict({'K': 'k', 'Key': 'Value'})
+
+ finally:
+ sys.stdout = saved_stdout
+
+ self.assertEqual(output_list.getvalue(), '''\
++-------+--------------+
+| ID | Name |
++-------+--------------+
+| | Name1 |
+| 1 | another |
+| 65536 | veeeery long |
++-------+--------------+
+''')
+
+ self.assertEqual(output_dict.getvalue(), '''\
++----------+-------+
+| Property | Value |
++----------+-------+
+| K | k |
+| Key | Value |
++----------+-------+
+''')
+
def test_ensure_str(self):
ensure_str = utils.ensure_str
self.assertEqual("True", ensure_str(True))
diff --git a/tools/pip-requires b/tools/pip-requires
index e5a9941..7aaf5da 100644
--- a/tools/pip-requires
+++ b/tools/pip-requires
@@ -1,5 +1,5 @@
argparse
-prettytable>=0.6,<0.7
+prettytable>=0.6,<0.8
python-keystoneclient>=0.1.2,<1
pyOpenSSL
warlock>=0.7.0,<2