r21725 - gnucash/trunk/src/optional/python-bindings/tests - [Testing] Suppress expected messages in optional/python-bindings tests

John Ralls jralls at code.gnucash.org
Mon Dec 12 17:41:51 EST 2011


Author: jralls
Date: 2011-12-12 17:41:51 -0500 (Mon, 12 Dec 2011)
New Revision: 21725
Trac: http://svn.gnucash.org/trac/changeset/21725

Modified:
   gnucash/trunk/src/optional/python-bindings/tests/Makefile.am
   gnucash/trunk/src/optional/python-bindings/tests/test_split.py
   gnucash/trunk/src/optional/python-bindings/tests/test_transaction.py
Log:
[Testing] Suppress expected messages in optional/python-bindings tests

Modified: gnucash/trunk/src/optional/python-bindings/tests/Makefile.am
===================================================================
--- gnucash/trunk/src/optional/python-bindings/tests/Makefile.am	2011-12-12 22:41:41 UTC (rev 21724)
+++ gnucash/trunk/src/optional/python-bindings/tests/Makefile.am	2011-12-12 22:41:51 UTC (rev 21725)
@@ -3,6 +3,8 @@
   GNC_BUILDDIR=`\cd ${top_builddir} && pwd` \
   PYTHONPATH=$(PYTHONPATH):$(top_builddir)/src/optional/python-bindings \
   PYTHONPATH=$$PYTHONPATH:$(top_builddir)/src/optional/python-bindings/.libs \
+  PYTHONPATH=$$PYTHONPATH:$(top_builddir)/src/test-core/ \
+  PYTHONPATH=$$PYTHONPATH:$(top_builddir)/src/test-core/.libs \
   $(top_builddir)/src/bin/overrides/gnucash-build-env $(PYTHON)
 TESTS = runTests.py
 

Modified: gnucash/trunk/src/optional/python-bindings/tests/test_split.py
===================================================================
--- gnucash/trunk/src/optional/python-bindings/tests/test_split.py	2011-12-12 22:41:41 UTC (rev 21724)
+++ gnucash/trunk/src/optional/python-bindings/tests/test_split.py	2011-12-12 22:41:51 UTC (rev 21725)
@@ -1,14 +1,19 @@
 from unittest import main
 
 from gnucash import Book, Account, Split, Transaction
+from test_stuff import *
 
 from test_book import BookSession
 
 class SplitSession( BookSession ):
     def setUp(self):
+
         BookSession.setUp(self)
         self.split = Split(self.book)
 
+    def tearDown(self):
+        pass
+
 class TestSplit( SplitSession ):
     def test_memo(self):
         MEMO = "cookie monster"
@@ -23,12 +28,32 @@
         self.assertTrue( ACCT.Equal(self.split.GetAccount(), True) )
 
     def test_transaction(self):
+        domain1 = "gnc.engine.scrub"
+        msg1 = "[xaccScrubUtilityGetOrMakeAccount()] No currency specified!"
+        level = G_LOG_LEVEL_CRITICAL
+        check1 = TestErrorStruct()
+        check1.log_domain = domain1
+        check1.log_level = level
+        check1.msg = msg1
+        hdlr1 = test_set_checked_handler(domain1, level, check1)
+        domain2 = "gnc.engine"
+        msg2 = "[xaccTransScrubSplits()] Transaction doesn't have a currency!"
+        level = G_LOG_LEVEL_CRITICAL
+        check2 = TestErrorStruct()
+        check2.log_domain = domain2
+        check2.log_level = level
+        check2.msg = msg2
+        hdlr2 = test_set_checked_handler(domain2, level, check2)
+
         TRANS = Transaction(self.book)
         self.split.SetParent(TRANS)
         TRANS.SetCurrency(self.currency)
         TRANS.SetDescription("Foo")
         self.assertEquals( TRANS.GetDescription(), self.split.GetParent().GetDescription() )
 
+        g_log_remove_handler(domain2, hdlr2)
+        g_log_remove_handler(domain1, hdlr1)
+
     def test_equal(self):
         COPY = self.split
         self.assertTrue( self.split.Equal(COPY, True, False, False) )

Modified: gnucash/trunk/src/optional/python-bindings/tests/test_transaction.py
===================================================================
--- gnucash/trunk/src/optional/python-bindings/tests/test_transaction.py	2011-12-12 22:41:41 UTC (rev 21724)
+++ gnucash/trunk/src/optional/python-bindings/tests/test_transaction.py	2011-12-12 22:41:51 UTC (rev 21725)
@@ -1,11 +1,31 @@
 from unittest import main
 
 from gnucash import Transaction, Book, Account, Split
+from test_stuff import *
 
 from test_book import BookSession
 
 class TransactionSession( BookSession ):
     def setUp(self):
+        self.domain1 = "gnc.engine"
+        self.domain2 = "gnc.engine.scrub"
+        level =  G_LOG_LEVEL_CRITICAL
+        check1 = TestErrorStruct()
+        check1.log_domain = self.domain1
+        check1.log_level = level
+        check1.msg = "[xaccScrubUtilityGetOrMakeAccount()] No currency specified!"
+        test_add_error(check1)
+        check2 = TestErrorStruct()
+        check2.log_domain = self.domain1
+        check2.log_level = level
+        check2.msg = "[xaccTransScrubSplits()] Transaction doesn't have a currency!"
+        test_add_error(check2)
+        self.hdlr1 = test_set_list_handler(self.domain1, level, None)
+        check3 = TestErrorStruct()
+        check3.log_domain = "gnc.engine.scrub"
+        check3.log_level = level
+        check3.msg = "[xaccScrubUtilityGetOrMakeAccount()] No currency specified!"
+        self.hdlr2 = test_set_checked_handler(self.domain2, level, check3)
         BookSession.setUp(self)
         self.trans = Transaction(self.book)
         #Evil bug means we must set a split for the transaction before making
@@ -15,18 +35,33 @@
         ############
         self.trans.SetCurrency(self.currency)
 
+    def tearDown(self):
+        g_log_remove_handler(self.domain1, self.hdlr1)
+        g_log_remove_handler(self.domain2, self.hdlr2)
+        test_clear_error_list ()
+
 class TestTransaction( TransactionSession ):
     def test_equal(self):
         TRANS = self.trans
         self.assertTrue( TRANS.Equal(self.trans, True, False, False, False) )
 
     def test_clone(self):
+        domain = "gnc.engine"
+        level =  G_LOG_LEVEL_WARNING
+        check = TestErrorStruct()
+        check.log_domain = domain
+        check.log_level = level
+        check.msg = "[xaccTransEqual()] GUIDs differ"
+        hdlr = test_set_checked_handler(domain, level, check)
+
         TRANS = self.trans.Clone()
-        #Clone and original should have different GUIDs
+       #Clone and original should have different GUIDs
         self.assertFalse( TRANS.Equal(self.trans, True, False, False, False) )
         #Clone and original should have the same balance
         self.assertTrue( TRANS.Equal(self.trans, False, False, True, False) )
 
+        g_log_remove_handler(domain, hdlr)
+
     def test_setcurrency(self):
         self.assertTrue( self.currency.equal( self.trans.GetCurrency() ) )
 



More information about the gnucash-changes mailing list