mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
fix __eq__ in Split and Transaction
Compare guids with .Equal() when comparing Split and Transaction instances.
This commit is contained in:
@@ -434,6 +434,9 @@ class Transaction(GnuCashCoreClass):
|
||||
return self.do_lookup_create_oo_instance(
|
||||
gncInvoiceGetInvoiceFromTxn, Transaction )
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.Equal(other, True, False, False, False)
|
||||
|
||||
def decorate_monetary_list_returning_function(orig_function):
|
||||
def new_function(self, *args):
|
||||
"""decorate function that returns list of gnc_monetary to return tuples of GncCommodity and GncNumeric
|
||||
@@ -461,6 +464,9 @@ class Split(GnuCashCoreClass):
|
||||
"""
|
||||
_new_instance = 'xaccMallocSplit'
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.Equal(other, True, False, False)
|
||||
|
||||
class Account(GnuCashCoreClass):
|
||||
"""A GnuCash Account.
|
||||
|
||||
|
||||
@@ -57,6 +57,11 @@ class TestSplit( SplitSession ):
|
||||
def test_equal(self):
|
||||
COPY = self.split
|
||||
self.assertTrue( self.split.Equal(COPY, True, False, False) )
|
||||
# test __eq__ implementation
|
||||
TRANS = Transaction(self.book)
|
||||
self.split.SetParent(TRANS)
|
||||
self.assertTrue( self.split == TRANS.GetSplitList()[0] )
|
||||
self.assertTrue( self.split != Split(self.book) )
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -44,6 +44,11 @@ class TestTransaction( TransactionSession ):
|
||||
def test_equal(self):
|
||||
TRANS = self.trans
|
||||
self.assertTrue( TRANS.Equal(self.trans, True, False, False, False) )
|
||||
# test __eq__ implementation
|
||||
SPLIT = Split(self.book)
|
||||
SPLIT.SetParent(TRANS)
|
||||
self.assertTrue( self.trans == SPLIT.GetParent() )
|
||||
self.assertTrue( self.trans != Transaction(self.book) )
|
||||
|
||||
def test_clone(self):
|
||||
domain = "gnc.engine"
|
||||
|
||||
Reference in New Issue
Block a user