Commit 6e976142 authored by Tres Seaver's avatar Tres Seaver

Make setting 'txn.user = None' raise ValueError.

parent f8d611a2
......@@ -136,10 +136,9 @@ class Transaction(object):
@user.setter
def user(self, v):
if v is not None:
self._user = text_or_warn(v)
else:
self._user = u""
if v is None:
raise ValueError("user must not be None")
self._user = text_or_warn(v)
@property
def description(self):
......
......@@ -1063,8 +1063,9 @@ class TransactionTests(unittest.TestCase):
def test_user_w_none(self):
txn = self._makeOne()
txn.user = b'phreddy'
txn.user = None # resets to empty text
self.assertEqual(txn.user, u'')
with self.assertRaises(ValueError):
txn.user = None # resets to empty text
self.assertEqual(txn.user, b'phreddy')
def _test_user_non_text(self, user, path, expect, both=False):
txn = self._makeOne()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment