Changeset - 87e715df7cec
[Not reviewed]
0 2 0
Brett Smith - 4 years ago 2020-07-16 14:39:48
brettcsmith@brettcsmith.org
tests: Make clean_account_meta a teardown fixture.
2 files changed with 4 insertions and 3 deletions:
0 comments (0 inline, 0 general)
tests/test_data_account.py
Show inline comments
...
 
@@ -283,25 +283,25 @@ def test_is_account(account_s):
 
    'Assets:Bank:12-345',
 
    'Equity:Funds:Restricted',
 
    'Expenses:Other',
 
    'Income:Donations',
 
    'Liabilities:CreditCard:Visa0123',
 
])
 
def test_is_account(clean_account_meta, account_s):
 
def test_is_account(account_s):
 
    assert data.Account.is_account(account_s)
 

	
 
@pytest.mark.parametrize('account_s', [
 
    'Assets:checking',
 
    'Assets::Cash',
 
    'Equity',
 
    'Liabilities:Credit Card',
 
    'income:Donations',
 
    'Expenses:Banking_Fees',
 
    'Revenue:Grants',
 
])
 
def test_is_not_account(clean_account_meta, account_s):
 
def test_is_not_account(account_s):
 
    assert not data.Account.is_account(account_s)
 

	
 
@pytest.mark.parametrize('account_s,expected', [
 
    ('Revenue:Donations', True),
 
    ('Costs:Other', True),
 
    ('Income:Donations', False),
tests/testutil.py
Show inline comments
...
 
@@ -37,16 +37,17 @@ EXTREME_FUTURE_DATE = datetime.date(datetime.MAXYEAR, 12, 30)
 
FUTURE_DATE = datetime.date.today() + datetime.timedelta(days=365 * 99)
 
FY_START_DATE = datetime.date(2020, 3, 1)
 
FY_MID_DATE = datetime.date(2020, 9, 1)
 
PAST_DATE = datetime.date(2000, 1, 1)
 
TESTS_DIR = Path(__file__).parent
 

	
 
# This function is primarily used as a fixture, but different test files use
 
# This function is a teardown fixture, but different test files use
 
# it with different scopes. Typical usage looks like:
 
#   clean_account_meta = pytest.fixture([options])(testutil.clean_account_meta)
 
def clean_account_meta():
 
    yield
 
    data.Account.load_options_map(bc_options.OPTIONS_DEFAULTS)
 
    data.Account._meta_map.clear()
 

	
 
def _ods_cell_value_type(cell):
 
    assert cell.tagName == 'table:table-cell'
 
    return cell.getAttribute('valuetype')
0 comments (0 inline, 0 general)