Skip to content

Commit

Permalink
implement excellent reviewer suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Fulton committed Nov 16, 2016
1 parent 32bd5a7 commit 665f559
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
7 changes: 4 additions & 3 deletions transaction/_manager.py
Expand Up @@ -175,15 +175,16 @@ def run(self, func=None, tries=3):
doc = func.__doc__
if name != '_':
if doc:
doc = name + u'\n\n' + doc
doc = name + '\n\n' + doc
else:
doc = name

if doc and not isinstance(doc, text_type):
doc = doc.decode('utf-8')

for i in range(1, tries + 1):
txn = self.begin()
if doc:
if not isinstance(doc, text_type):
doc = doc.decode('ascii')
txn.note(doc)

try:
Expand Down
2 changes: 1 addition & 1 deletion transaction/_transaction.py
Expand Up @@ -548,7 +548,7 @@ def setUser(self, user_name, path=u"/"):
if not isinstance(user_name, text_type):
raise TypeError("User name must be text (unicode)")
if not isinstance(path, text_type):
raise TypeError("User name must be text (unicode)")
raise TypeError("Path must be text (unicode)")
self.user = u"%s %s" % (path, user_name)

def setExtendedInfo(self, name, value):
Expand Down
10 changes: 5 additions & 5 deletions transaction/tests/test__transaction.py
Expand Up @@ -992,7 +992,7 @@ def test_note(self):

def test_description_bytes(self):
txn = self._makeOne()
with self.assertRaises((UnicodeDecodeError, TypeError)):
with self.assertRaises(TypeError):
txn.description = b'haha'

def test_setUser_default_path(self):
Expand All @@ -1007,13 +1007,13 @@ def test_setUser_explicit_path(self):

def test_user_bytes(self):
txn = self._makeOne()
with self.assertRaises((UnicodeDecodeError, TypeError)):
with self.assertRaises(TypeError):
txn.user = b'phreddy'
with self.assertRaises((UnicodeDecodeError, TypeError)):
with self.assertRaises(TypeError):
txn.setUser(b'phreddy', u'/bedrock')
with self.assertRaises((UnicodeDecodeError, TypeError)):
with self.assertRaises(TypeError):
txn.setUser(u'phreddy', b'/bedrock')
with self.assertRaises((UnicodeDecodeError, TypeError)):
with self.assertRaises(TypeError):
txn.setUser(b'phreddy')

def test_setExtendedInfo_single(self):
Expand Down

0 comments on commit 665f559

Please sign in to comment.