aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/util/id.py
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2024-01-18 19:09:58 +0100
committerMatěj Cepl <mcepl@cepl.eu>2024-01-18 19:09:58 +0100
commitcc7362d28bd9c43cb6839809f86e59874f2fe458 (patch)
tree1053748f5890c769d1e99806bc0c8bcffca6f0fe /libbe/util/id.py
parent003bd13629d9db2f14156f97b74a4672e9ecdf77 (diff)
downloadbugseverywhere-cc7362d28bd9c43cb6839809f86e59874f2fe458.tar.gz
2to3 conversion of the repo.
Diffstat (limited to 'libbe/util/id.py')
-rw-r--r--libbe/util/id.py48
1 files changed, 24 insertions, 24 deletions
diff --git a/libbe/util/id.py b/libbe/util/id.py
index de9edf9..078dd3f 100644
--- a/libbe/util/id.py
+++ b/libbe/util/id.py
@@ -103,14 +103,14 @@ except ImportError:
# win32 don't have os.execvp() so have to run command in a shell
q = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE,
shell=True, cwd=cwd)
- except OSError, e :
+ except OSError as e :
strerror = "%s\nwhile executing %s" % (e.args[1], args)
- raise OSError, strerror
+ raise OSError(strerror)
output, error = q.communicate()
status = q.wait()
if status != 0:
strerror = "%s\nwhile executing %s" % (status, args)
- raise Exception, strerror
+ raise Exception(strerror)
return output.rstrip('\n')
@@ -414,11 +414,11 @@ def long_to_short_user(bugdirs, id):
long_to_short_text : conversion on a block of text
"""
ids = _split(id, check_length=True)
- matching_bugdirs = [bd for bd in bugdirs.values() if bd.uuid == ids[0]]
+ matching_bugdirs = [bd for bd in list(bugdirs.values()) if bd.uuid == ids[0]]
if len(matching_bugdirs) == 0:
- raise NoIDMatches(id, [bd.uuid for bd in bugdirs.values()])
+ raise NoIDMatches(id, [bd.uuid for bd in list(bugdirs.values())])
elif len(matching_bugdirs) > 1:
- raise MultipleIDMatches(id, '', [bd.uuid for bd in bugdirs.values()])
+ raise MultipleIDMatches(id, '', [bd.uuid for bd in list(bugdirs.values())])
bugdir = matching_bugdirs[0]
objects = [bugdir]
if len(ids) >= 2:
@@ -443,10 +443,10 @@ def short_to_long_user(bugdirs, id):
"""
ids = _split(id, check_length=True)
ids[0] = _expand(ids[0], common=None,
- other_ids=[bd.uuid for bd in bugdirs.values()])
+ other_ids=[bd.uuid for bd in list(bugdirs.values())])
if len(ids) == 1:
return _assemble(ids)
- bugdir = [bd for bd in bugdirs.values() if bd.uuid == ids[0]][0]
+ bugdir = [bd for bd in list(bugdirs.values()) if bd.uuid == ids[0]][0]
ids[1] = _expand(ids[1], common=bugdir.id.user(),
other_ids=bugdir.uuids())
if len(ids) == 2:
@@ -603,7 +603,7 @@ if libbe.TESTING == True:
class UUIDtestCase(unittest.TestCase):
def testUUID_gen(self):
id = uuid_gen()
- self.failUnless(len(id) == 36, 'invalid UUID "%s"' % id)
+ self.assertTrue(len(id) == 36, 'invalid UUID "%s"' % id)
class DummyObject (object):
def __init__(self, uuid, parent=None, siblings=[]):
@@ -629,31 +629,31 @@ if libbe.TESTING == True:
self.b_id = self.bug.id
self.c_id = self.comment.id
def test_storage(self):
- self.failUnless(self.bd_id.storage() == self.bugdir.uuid,
+ self.assertTrue(self.bd_id.storage() == self.bugdir.uuid,
self.bd_id.storage())
- self.failUnless(self.b_id.storage() == self.bug.uuid,
+ self.assertTrue(self.b_id.storage() == self.bug.uuid,
self.b_id.storage())
- self.failUnless(self.c_id.storage() == self.comment.uuid,
+ self.assertTrue(self.c_id.storage() == self.comment.uuid,
self.c_id.storage())
- self.failUnless(self.bd_id.storage('x', 'y', 'z') == \
+ self.assertTrue(self.bd_id.storage('x', 'y', 'z') == \
'1234abcd/x/y/z',
self.bd_id.storage('x', 'y', 'z'))
def test_long_user(self):
- self.failUnless(self.bd_id.long_user() == self.bugdir.uuid,
+ self.assertTrue(self.bd_id.long_user() == self.bugdir.uuid,
self.bd_id.long_user())
- self.failUnless(self.b_id.long_user() == \
+ self.assertTrue(self.b_id.long_user() == \
'/'.join([self.bugdir.uuid, self.bug.uuid]),
self.b_id.long_user())
- self.failUnless(self.c_id.long_user() ==
+ self.assertTrue(self.c_id.long_user() ==
'/'.join([self.bugdir.uuid, self.bug.uuid,
self.comment.uuid]),
self.c_id.long_user)
def test_user(self):
- self.failUnless(self.bd_id.user() == '123',
+ self.assertTrue(self.bd_id.user() == '123',
self.bd_id.user())
- self.failUnless(self.b_id.user() == '123/abc',
+ self.assertTrue(self.b_id.user() == '123/abc',
self.b_id.user())
- self.failUnless(self.c_id.user() == '123/abc/12345',
+ self.assertTrue(self.c_id.user() == '123/abc/12345',
self.c_id.user())
class ShortLongParseTestCase(unittest.TestCase):
@@ -690,12 +690,12 @@ if libbe.TESTING == True:
None, '123/abc', ['1234abcd','1234cdef','12345678'])),
]
def test_short_to_long_text(self):
- self.failUnless(short_to_long_text(
+ self.assertTrue(short_to_long_text(
self.bugdirs, self.short) == self.long,
'\n' + self.short + '\n' + short_to_long_text(
self.bugdirs, self.short) + '\n' + self.long)
def test_long_to_short_text(self):
- self.failUnless(long_to_short_text(
+ self.assertTrue(long_to_short_text(
self.bugdirs, self.long) == self.short,
'\n' + long_to_short_text(
self.bugdirs, self.long
@@ -703,7 +703,7 @@ if libbe.TESTING == True:
def test_parse_user(self):
for short_id,parsed in self.short_id_parse_pairs:
ret = parse_user(self.bugdirs, short_id)
- self.failUnless(ret == parsed,
+ self.assertTrue(ret == parsed,
'got %s\nexpected %s' % (ret, parsed))
def test_parse_user_exceptions(self):
for short_id,exception in self.short_id_exception_pairs:
@@ -712,13 +712,13 @@ if libbe.TESTING == True:
self.fail('Expected parse_user(bugdir, "%s") to raise %s,'
'\n but it returned %s'
% (short_id, exception.__class__.__name__, ret))
- except exception.__class__, e:
+ except exception.__class__ as e:
for attr in dir(e):
if attr.startswith('_') or attr == 'args':
continue
value = getattr(e, attr)
expected = getattr(exception, attr)
- self.failUnless(
+ self.assertTrue(
value == expected,
'Expected parse_user(bugdir, "%s") %s.%s'
'\n to be %s, but it is %s\n\n%s'