Skip to content

Commit

Permalink
Merge pull request #67 from megapctr/repr-fix
Browse files Browse the repository at this point in the history
Improved Money.__repr__
  • Loading branch information
spookylukey committed Mar 31, 2016
2 parents ddeedc2 + 67bad0a commit 5476604
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions moneyed/classes.py
Expand Up @@ -3,7 +3,7 @@
from __future__ import division
from __future__ import unicode_literals

from decimal import Decimal, ROUND_DOWN
from decimal import Decimal
import sys
import warnings

Expand Down Expand Up @@ -85,8 +85,7 @@ def __init__(self, amount=Decimal('0.0'), currency=DEFAULT_CURRENCY_CODE):
self.currency = currency

def __repr__(self):
return "%s %s" % (self.amount.to_integral_value(ROUND_DOWN),
self.currency)
return "<Money: %s %s>" % (self.amount, self.currency)

def __unicode__(self):
from moneyed.localization import format_money
Expand Down
10 changes: 5 additions & 5 deletions moneyed/test_moneyed_classes.py
Expand Up @@ -104,11 +104,11 @@ def test_init_float(self):
assert one_million_dollars.amount == self.one_million_decimal

def test_repr(self):
assert repr(self.one_million_bucks) == '1000000 USD'
assert repr(Money(Decimal('2.000'), 'PLN')) == '2 PLN'
m_1 = Money(Decimal('2.000'), 'PLN')
m_2 = Money(Decimal('2.000000'), 'PLN')
assert repr(m_1) == repr(m_2)
assert repr(self.one_million_bucks) == '<Money: 1000000 USD>'
assert repr(Money(Decimal('2.000'), 'PLN')) == '<Money: 2.000 PLN>'
m_1 = Money(Decimal('2.00'), 'PLN')
m_2 = Money(Decimal('2.01'), 'PLN')
assert repr(m_1) != repr(m_2)

def test_str(self):
assert str(self.one_million_bucks) == 'US$1,000,000.00'
Expand Down

0 comments on commit 5476604

Please sign in to comment.