GnuCash c935c2f+
Loading...
Searching...
No Matches
Public Member Functions
test_price_and_wrapping.TestDoubleWrapProtection Class Reference
Inheritance diagram for test_price_and_wrapping.TestDoubleWrapProtection:

Public Member Functions

 test_gnc_numeric_double_wrap (self)
 
 test_gnc_numeric_double_wrap_arithmetic (self)
 
 test_gnc_commodity_double_wrap (self)
 
 test_raw_instance_still_works (self)
 

Detailed Description

Verify that passing a wrapper object as instance= to a wrapper
class constructor unwraps it instead of creating a broken object.

Definition at line 421 of file test_price_and_wrapping.py.

Member Function Documentation

◆ test_gnc_commodity_double_wrap()

test_price_and_wrapping.TestDoubleWrapProtection.test_gnc_commodity_double_wrap (   self)

Definition at line 437 of file test_price_and_wrapping.py.

437 def test_gnc_commodity_double_wrap(self):
438 ses = Session()
439 book = ses.get_book()
440 table = book.get_table()
441 usd = table.lookup("CURRENCY", "USD")
442 double = GncCommodity(instance=usd)
443 self.assertIsInstance(double, GncCommodity)
444 self.assertEqual(double.get_mnemonic(), "USD")
445 ses.end()
446

◆ test_gnc_numeric_double_wrap()

test_price_and_wrapping.TestDoubleWrapProtection.test_gnc_numeric_double_wrap (   self)

Definition at line 425 of file test_price_and_wrapping.py.

425 def test_gnc_numeric_double_wrap(self):
426 original = GncNumeric(7, 3)
427 double = GncNumeric(instance=original)
428 self.assertEqual(double.num(), 7)
429 self.assertEqual(double.denom(), 3)
430
The primary numeric class for representing amounts and values.

◆ test_gnc_numeric_double_wrap_arithmetic()

test_price_and_wrapping.TestDoubleWrapProtection.test_gnc_numeric_double_wrap_arithmetic (   self)

Definition at line 431 of file test_price_and_wrapping.py.

431 def test_gnc_numeric_double_wrap_arithmetic(self):
432 original = GncNumeric(1, 4)
433 double = GncNumeric(instance=original)
434 result = double + GncNumeric(3, 4)
435 self.assertAlmostEqual(float(result), 1.0, places=6)
436

◆ test_raw_instance_still_works()

test_price_and_wrapping.TestDoubleWrapProtection.test_raw_instance_still_works (   self)
Passing a raw SWIG proxy as instance= must still work.

Definition at line 447 of file test_price_and_wrapping.py.

447 def test_raw_instance_still_works(self):
448 """Passing a raw SWIG proxy as instance= must still work."""
449 from gnucash import gnucash_core_c as gc
450 raw = gc.gnc_numeric_create(5, 2)
451 val = GncNumeric(instance=raw)
452 self.assertEqual(val.num(), 5)
453 self.assertEqual(val.denom(), 2)
454
455

The documentation for this class was generated from the following file: