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

Public Member Functions

 test_wrapper_triggers_deprecation_warning (self)
 
 test_raw_instance_no_warning (self)
 
- Public Member Functions inherited from test_price_and_wrapping.PriceSession
 setUp (self)
 
 tearDown (self)
 

Additional Inherited Members

- Data Fields inherited from test_price_and_wrapping.PriceSession
 ses
 
 book
 
 table
 
 usd
 
 test_comm
 
 pricedb
 
 price1
 
 price2
 

Detailed Description

Verify that passing a ClassFromFunctions wrapper to a C function
still works (via the SWIG typemap) and emits a DeprecationWarning.

Definition at line 344 of file test_price_and_wrapping.py.

Member Function Documentation

◆ test_raw_instance_no_warning()

test_price_and_wrapping.TestSwigTypemapCompat.test_raw_instance_no_warning (   self)
Passing price.instance directly should NOT emit a warning.

Definition at line 368 of file test_price_and_wrapping.py.

368 def test_raw_instance_no_warning(self):
369 """Passing price.instance directly should NOT emit a warning."""
370 from gnucash import gnucash_core_c as gc
371
372 price = self.pricedb.lookup_latest(self.test_comm, self.usd)
373 if price is None:
374 self.skipTest("No price data")
375
376 with warnings.catch_warnings(record=True) as w:
377 warnings.simplefilter("always")
378 comm_instance = gc.gnc_price_get_commodity(price.instance)
379 dep_warnings = [x for x in w
380 if issubclass(x.category, DeprecationWarning)]
381 self.assertEqual(len(dep_warnings), 0,
382 "Unexpected DeprecationWarning for .instance")
383
384
385# ---------------------------------------------------------------------------
386# Test: GncPriceDB.get_*_price returns GncNumeric
387# ---------------------------------------------------------------------------

◆ test_wrapper_triggers_deprecation_warning()

test_price_and_wrapping.TestSwigTypemapCompat.test_wrapper_triggers_deprecation_warning (   self)
Passing a GncPrice wrapper to gnucash_core_c should emit
DeprecationWarning and still return a valid result.

Definition at line 348 of file test_price_and_wrapping.py.

348 def test_wrapper_triggers_deprecation_warning(self):
349 """Passing a GncPrice wrapper to gnucash_core_c should emit
350 DeprecationWarning and still return a valid result."""
351 from gnucash import gnucash_core_c as gc
352
353 price = self.pricedb.lookup_latest(self.test_comm, self.usd)
354 if price is None:
355 self.skipTest("No price data")
356
357 self.assertIsInstance(price, GncPrice)
358
359 with warnings.catch_warnings(record=True) as w:
360 warnings.simplefilter("always")
361 # Pass the wrapper object directly — typemap should unwrap it
362 comm_instance = gc.gnc_price_get_commodity(price)
363 dep_warnings = [x for x in w
364 if issubclass(x.category, DeprecationWarning)]
365 self.assertGreater(len(dep_warnings), 0,
366 "Expected DeprecationWarning from typemap")
367

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