]> www.infradead.org Git - users/hch/nvmetcli.git/commitdiff
test_nvmet.py: test_invalid_input fails for py3
authorTony Asleson <tasleson@redhat.com>
Thu, 26 Mar 2020 18:07:49 +0000 (13:07 -0500)
committerChristoph Hellwig <hch@lst.de>
Wed, 1 Apr 2020 09:00:14 +0000 (11:00 +0200)
When you run 'make test' using python 3 the unit test
test_invalid_input fails with:

Traceback (most recent call last):
  File "/someuser/projects/nvmetcli/nvmet/test_nvmet.py", line 395, in
test_invalid_input
    for i in range(l))
  File "/someuser/projects/nvmetcli/nvmet/test_nvmet.py", line 395, in
<genexpr>
    for i in range(l))
AttributeError: module 'string' has no attribute 'lowercase'

Python 3 does not have 'string.lowercase' ref.
https://docs.python.org/3/library/string.html

Python 2 does ref.
https://docs.python.org/2/library/string.html

Both have "string.ascii_lowercase" so lets leverage that to
support both.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
nvmet/test_nvmet.py

index 5caa5464170ca556e90d1a32835544983af12aed..aae4a8631107e734b20afcd320f8c3f60ecb3b18 100644 (file)
@@ -391,7 +391,7 @@ class TestNvmet(unittest.TestCase):
                           nqn='/', mode='create')
 
         for l in [ 257, 512, 1024, 2048 ]:
-            toolong = ''.join(random.choice(string.lowercase)
+            toolong = ''.join(random.choice(string.ascii_lowercase)
                               for i in range(l))
             self.assertRaises(nvme.CFSError, nvme.Subsystem,
                               nqn=toolong, mode='create')