GnuCash fec5643+
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 422 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 438 of file test_price_and_wrapping.py.

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

◆ test_gnc_numeric_double_wrap()

test_price_and_wrapping.TestDoubleWrapProtection.test_gnc_numeric_double_wrap (   self)

Definition at line 426 of file test_price_and_wrapping.py.

426 def test_gnc_numeric_double_wrap(self):
427 original = GncNumeric(7, 3)
428 double = GncNumeric(instance=original)
429 self.assertEqual(double.num(), 7)
430 self.assertEqual(double.denom(), 3)
431
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 432 of file test_price_and_wrapping.py.

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

◆ 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 448 of file test_price_and_wrapping.py.

448 def test_raw_instance_still_works(self):
449 """Passing a raw SWIG proxy as instance= must still work."""
450 from gnucash import gnucash_core_c as gc
451 raw = gc.gnc_numeric_create(5, 2)
452 val = GncNumeric(instance=raw)
453 self.assertEqual(val.num(), 5)
454 self.assertEqual(val.denom(), 2)
455
456
457# ---------------------------------------------------------------------------
458# Test: PriceSource enum stays in sync with the C PRICE_SOURCE_* enum
459# ---------------------------------------------------------------------------

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