Skip to content

Commit

Permalink
Allow for prettytable 0.7.x as well
Browse files Browse the repository at this point in the history
Relax requirements to >= 0.6, < 0.8, as 0.7.x seems to
work as well. Added testcase to ensure this.

Change-Id: I1a1a709e6053451b1256a0d78f8fe8562fb10e62
  • Loading branch information
dirkmueller committed Mar 15, 2013
1 parent 6c7fb0e commit 31960f0
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
43 changes: 43 additions & 0 deletions tests/test_utils.py
Expand Up @@ -15,6 +15,8 @@

import errno
import testtools
import sys
import StringIO

from glanceclient.common import utils

Expand Down Expand Up @@ -69,6 +71,47 @@ def test_ensure_unicode(self):
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))
Expand Down
2 changes: 1 addition & 1 deletion 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

0 comments on commit 31960f0

Please sign in to comment.