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
This commit is contained in:
@@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
import errno
|
import errno
|
||||||
import testtools
|
import testtools
|
||||||
|
import sys
|
||||||
|
import StringIO
|
||||||
|
|
||||||
from glanceclient.common import utils
|
from glanceclient.common import utils
|
||||||
|
|
||||||
@@ -69,6 +71,47 @@ class TestUtils(testtools.TestCase):
|
|||||||
self.assertEqual(u'ni\xf1o', ensure_unicode('ni\xc3\xb1o',
|
self.assertEqual(u'ni\xf1o', ensure_unicode('ni\xc3\xb1o',
|
||||||
incoming='ascii'))
|
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):
|
def test_ensure_str(self):
|
||||||
ensure_str = utils.ensure_str
|
ensure_str = utils.ensure_str
|
||||||
self.assertEqual("True", ensure_str(True))
|
self.assertEqual("True", ensure_str(True))
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
argparse
|
argparse
|
||||||
prettytable>=0.6,<0.7
|
prettytable>=0.6,<0.8
|
||||||
python-keystoneclient>=0.1.2,<1
|
python-keystoneclient>=0.1.2,<1
|
||||||
pyOpenSSL
|
pyOpenSSL
|
||||||
warlock>=0.7.0,<2
|
warlock>=0.7.0,<2
|
||||||
|
Reference in New Issue
Block a user