Skip to content
Browse files

Reduce noise in repr output

  • Loading branch information...
1 parent e7753e4 commit 4df4bced8a3f3e472664f166343cdcafe5e8554d @patrys patrys committed Sep 12, 2012
Showing with 6 additions and 6 deletions.
  1. +1 −1 README.rst
  2. +4 −4 prices/__init__.py
  3. +1 −1 prices/tests/test_prices.py
View
2 README.rst
@@ -30,4 +30,4 @@ And being helpful::
>>> p += price(50)
>>> p += lineartax('1.23', '23% VAT')
>>> inspect_price(p)
- "price(Decimal('1.99'), currency=None) + price(Decimal('50'), currency=None) + lineartax(Decimal('1.23'), name='23% VAT')"
+ "price('1.99', currency=None) + price('50', currency=None) + lineartax('1.23', name='23% VAT')"
View
8 prices/__init__.py
@@ -25,9 +25,9 @@ def __init__(self, net, gross=None, currency=None, previous=None,
def __repr__(self):
if self.net == self.gross:
- return 'price(%r, currency=%r)' % (self.net, self.currency)
+ return 'price(%r, currency=%r)' % (str(self.net), self.currency)
return ('price(net=%r, gross=%r, currency=%r)' %
- (self.net, self.gross, self.currency))
+ (str(self.net), str(self.gross), self.currency))
def __lt__(self, other):
if isinstance(other, price):
@@ -204,7 +204,7 @@ def __init__(self, multiplier, name=None):
self.name = name or self.name
def __repr__(self):
- return 'lineartax(%r, name=%r)' % (self.multiplier, self.name)
+ return 'lineartax(%r, name=%r)' % (str(self.multiplier), self.name)
def __lt__(self, other):
if not isinstance(other, lineartax):
@@ -231,7 +231,7 @@ def format_inspect(data):
if op is operator.__mul__:
return '(%s) * %r' % (format_inspect(op1), op2)
if op == price.quantize:
- return '(%s).quantize(%r)' % (format_inspect(op1), op2)
+ return '(%s).quantize(%r)' % (format_inspect(op1), str(op2))
return '%s + %s' % (format_inspect(op1), format_inspect(op2))
return repr(data)
return format_inspect(price_obj.inspect())
View
2 prices/tests/test_prices.py
@@ -53,7 +53,7 @@ def test_inspect(self):
p = ((self.ten_btc + self.twenty_btc) * 5 + tax).quantize('0.01')
self.assertEqual(
inspect_price(p),
- "((price(Decimal('10'), currency='BTC') + price(Decimal('20'), currency='BTC')) * 5 + lineartax(Decimal('1.2345678'), name='Silly Tax')).quantize(Decimal('0.01'))")
+ "((price('10', currency='BTC') + price('20', currency='BTC')) * 5 + lineartax('1.2345678', name='Silly Tax')).quantize('0.01')")
def test_elements(self):
tax = lineartax('1.2345678', name='Silly Tax')

0 comments on commit 4df4bce

Please sign in to comment.
Something went wrong with that request. Please try again.