Changeset 12790 for main/waeup.ikoba/trunk/src
- Timestamp:
- 18 Mar 2015, 14:08:18 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba/payments
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/payments/payment.py
r12788 r12790 258 258 self.amount = amount 259 259 260 def __repr__(self): 261 result = "%s(item_id=%r, title=%r, amount=%r)" % ( 262 self.__class__.__name__, self.item_id, self.title, self.amount) 263 return result 264 260 265 def to_string(self): 261 266 """A string representation that can be used in exports. -
main/waeup.ikoba/trunk/src/waeup/ikoba/payments/tests/test_payment.py
r12789 r12790 390 390 self.assertEqual( 391 391 obj.to_string(), u"(u'0', u'ümläut', u'0.00')") 392 393 def test_repr(self): 394 # we can get a proper representation of PaymentItem 395 obj = PaymentItem() 396 self.assertEqual( 397 repr(obj), 398 "PaymentItem(item_id=u'0', title=u'', amount=Decimal('0.00'))") 399 400 def test_repr_can_be_evaled(self): 401 # we can eval() representations 402 obj = PaymentItem( 403 item_id=u'12', title=u'My Title', amount=decimal.Decimal("1.99")) 404 representation = repr(obj) 405 self.assertEqual( 406 representation, 407 ("PaymentItem(item_id=u'12', title=u'My Title', " 408 "amount=Decimal('1.99'))") 409 ) 410 from decimal import Decimal 411 new_obj = eval(representation) 412 assert new_obj is not obj 413 assert new_obj.item_id == obj.item_id == u"12" 414 assert new_obj.title == obj.title == u"My Title" 415 assert new_obj.amount == obj.amount == Decimal("1.99")
Note: See TracChangeset for help on using the changeset viewer.