mirror of
https://git.wownero.com/lza_menace/wownero-python.git
synced 2024-08-15 03:25:25 +00:00
Add __format__() to Address
This commit is contained in:
parent
e55e2239b1
commit
b70c3fbc43
2 changed files with 6 additions and 0 deletions
|
@ -71,6 +71,9 @@ class BaseAddress(object):
|
|||
def __hash__(self):
|
||||
return hash(str(self))
|
||||
|
||||
def __format__(self, spec):
|
||||
return format(str(self), spec)
|
||||
|
||||
|
||||
class Address(BaseAddress):
|
||||
"""Monero address.
|
||||
|
|
|
@ -14,6 +14,7 @@ class Tests(object):
|
|||
def test_from_and_to_string(self):
|
||||
a = Address(self.addr)
|
||||
self.assertEqual(str(a), self.addr)
|
||||
self.assertEqual("{:s}".format(a), self.addr)
|
||||
self.assertEqual(a.spend_key(), self.psk)
|
||||
self.assertEqual(a.view_key(), self.pvk)
|
||||
self.assertEqual(hash(a), hash(self.addr))
|
||||
|
@ -21,12 +22,14 @@ class Tests(object):
|
|||
ia = IntegratedAddress(self.iaddr)
|
||||
self.assertEqual(ia.payment_id(), self.pid)
|
||||
self.assertEqual(str(ia), self.iaddr)
|
||||
self.assertEqual("{:s}".format(ia), self.iaddr)
|
||||
self.assertEqual(ia.spend_key(), self.psk)
|
||||
self.assertEqual(ia.view_key(), self.pvk)
|
||||
self.assertEqual(ia.base_address(), a)
|
||||
|
||||
sa = SubAddress(self.subaddr)
|
||||
self.assertEqual(str(sa), self.subaddr)
|
||||
self.assertEqual("{:s}".format(sa), self.subaddr)
|
||||
|
||||
def test_payment_id(self):
|
||||
a = Address(self.addr)
|
||||
|
|
Loading…
Reference in a new issue