Commits

Virgil Dupras committed c12d774

Use pytest-monkeyplus functionality instead of hscommon.testutil.patch_*.

Comments (0)

Files changed (27)

core/tests/budget_test.py

 # which should be included with this package. The terms are also available at 
 # http://www.hardcoded.net/licenses/bsd_license
 
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 
 from ..model.account import AccountType
 from .base import TestApp, with_app
 #-- Account with budget
 def app_account_with_budget(monkeypatch):
     # 4 days left to the month, 100$ monthly budget
-    patch_today(monkeypatch, 2008, 1, 27)
+    monkeypatch.patch_today(2008, 1, 27)
     app = TestApp()
     app.add_account('Some Income', account_type=AccountType.Income)
     app.add_budget('Some Income', None, '100')
 
 #--- Income with budget in past
 def app_income_with_budget_in_past(monkeypatch):
-    patch_today(monkeypatch, 2009, 11, 16)
+    monkeypatch.patch_today(2009, 11, 16)
     app = TestApp()
     app.add_account('income', account_type=AccountType.Income)
     app.add_budget('income', None, '100', start_date='01/09/2009')
 
 #--- Expense with budget and txn
 def app_budget_with_expense_and_txn(monkeypatch):
-    patch_today(monkeypatch, 2008, 1, 27)
+    monkeypatch.patch_today(2008, 1, 27)
     app = TestApp()
     app.add_account('Some Expense', account_type=AccountType.Expense)
     app.add_budget('Some Expense', None, '100')
 
 #--- Expense with budget and target
 def app_expense_with_budget_and_target(monkeypatch):
-    patch_today(monkeypatch, 2008, 1, 27)
+    monkeypatch.patch_today(2008, 1, 27)
     app = TestApp()
     app.add_account('some asset')
     app.add_account('Some Expense', account_type=AccountType.Expense)
 def app_two_budgets_from_same_account(monkeypatch):
     # XXX this mock is because the test previously failed because we were currently on the last
     # day of the month. TODO: Re-create the last-day condition and fix the calculation bug
-    patch_today(monkeypatch, 2009, 8, 20)
+    monkeypatch.patch_today(2009, 8, 20)
     app = TestApp()
     app.drsel.select_month_range()
     app.add_account('income', account_type=AccountType.Income)
 
 #--- Yearly buget with txn before current month
 def app_yearly_budget_with_txn_before_current_month(monkeypatch):
-    patch_today(monkeypatch, 2009, 8, 24)
+    monkeypatch.patch_today(2009, 8, 24)
     app = TestApp()
     app.drsel.select_year_range()
     app.add_account('income', account_type=AccountType.Income)
 
 #--- Scheduled txn and budget
 def app_scheduled_txn_and_budget(monkeypatch):
-    patch_today(monkeypatch, 2009, 9, 10)
+    monkeypatch.patch_today(2009, 9, 10)
     app = TestApp()
     app.drsel.select_month_range()
     app.add_account('account', account_type=AccountType.Expense)

core/tests/completion_test.py

 
 import time
 
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 
 from .base import TestApp, with_app
 from ..model.account import AccountType
 @with_app(app_four_entries_with_description_and_category_collision)
 def test_persistence_of_completion(app, tmpdir, monkeypatch):
     # Completion (including its order) is persistent.
-    patch_today(monkeypatch, 2007, 10, 6) # the test fails otherwise
+    monkeypatch.patch_today(2007, 10, 6) # the test fails otherwise
     row = app.etable.selected_row
     row.transfer = 'cat12'
     app.etable.save_edits()

core/tests/conftest.py

 global_monkeypatch = None
 original_rates_db_ensure_rates = RatesDB.ensure_rates
 
-def get_testunit(item):
-    if hasattr(item, 'obj'):
-        testunit = py.builtin._getimself(item.obj)
-        if hasattr(testunit, 'global_setup'):
-            return testunit
-
-def pytest_runtest_setup(item):
-    testunit = get_testunit(item)
-    if testunit is not None:
-        testunit.global_setup()
-
-def pytest_runtest_teardown(item):
-    testunit = get_testunit(item)
-    if testunit is not None:
-        testunit.global_teardown()
-
 def pytest_configure(config):
     global global_monkeypatch
     monkeypatch = config.pluginmanager.getplugin('monkeypatch')
 
 def get_original_rates_db_ensure_rates():
     return original_rates_db_ensure_rates
+
+def pytest_funcarg__monkeypatch(request):
+    monkeyplus = request.getfuncargvalue('monkeyplus')
+    return monkeyplus

core/tests/date_range_test.py

 
 from datetime import date
 
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 
 from ..const import PaneType
 from ..model.account import AccountType
 #---
 class TestRangeOnOctober2007:
     def do_setup(self, monkeypatch):
-        patch_today(monkeypatch, 2007, 10, 1)
+        monkeypatch.patch_today(2007, 10, 1)
         app = TestApp()
         app.drsel.select_month_range()
         app.clear_gui_calls()
 
 #--- Range on year 2007
 def app_range_on_year2007(monkeypatch):
-    patch_today(monkeypatch, 2007, 1, 1)
+    monkeypatch.patch_today(2007, 1, 1)
     app = TestApp()
     return app
 
 #---
 class TestRangeOnYearStartsOnApril:
     def do_setup(self, monkeypatch):
-        patch_today(monkeypatch, 2007, 4, 1)
+        monkeypatch.patch_today(2007, 4, 1)
         app = TestApp()
         app.drsel.select_year_range()
         app.app.year_start_month = 4
 
 #---
 def app_range_on_year_to_date(monkeypatch):
-    patch_today(monkeypatch, 2008, 11, 12)
+    monkeypatch.patch_today(2008, 11, 12)
     app = TestApp()
     app.drsel.select_year_to_date_range()
     return app
 class TestRangeOnRunningYear:
     def do_setup(self, monkeypatch):
         app = TestApp()
-        patch_today(monkeypatch, 2009, 1, 25)
+        monkeypatch.patch_today(2009, 1, 25)
         app.drsel.select_running_year_range()
         app.clear_gui_calls()
         return app
 class TestRangeOnRunningYearWithAheadMonths:
     def do_setup(self, monkeypatch):
         app = TestApp()
-        patch_today(monkeypatch, 2009, 1, 25)
+        monkeypatch.patch_today(2009, 1, 25)
         app.app.ahead_months = 5
         app.drsel.select_running_year_range()
         app.clear_gui_calls()
 #---
 class TestAllTransactionsRangeWithOneTransactionFarInThePast:
     def do_setup(self, monkeypatch):
-        patch_today(monkeypatch, 2010, 1, 10)
+        monkeypatch.patch_today(2010, 1, 10)
         app = TestApp()
         app.add_txn('01/10/1981', from_='foo', to='bar', amount='42')
         app.add_txn('10/01/2010')

core/tests/gui/account_pie_chart_test.py

 
 from datetime import date
 
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 from hscommon.currency import Currency, USD, CAD
 
 from ..base import ApplicationGUI, TestApp, with_app
 from ...model.account import AccountType
 
 def app_some_assets_and_liabilities(monkeypatch):
-    patch_today(monkeypatch, 2009, 1, 29) # On the last day of the month, some tests fail
+    monkeypatch.patch_today(2009, 1, 29) # On the last day of the month, some tests fail
     app = TestApp()
     app.drsel.select_month_range()
     app.add_account('a1')
     @with_app(do_setup)
     def test_budget(self, app, monkeypatch):
         # budgeted amounts are also reflected in the pie chart
-        patch_today(monkeypatch, 2009, 1, 29) # On the last day of the month, this test fails
+        monkeypatch.patch_today(2009, 1, 29) # On the last day of the month, this test fails
         app.add_budget('e1', None, '5')
         app.mw.select_income_statement()
         expected = [

core/tests/gui/balance_graph_test.py

 # which should be included with this package. The terms are also available at 
 # http://www.hardcoded.net/licenses/bsd_license
 
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 from hscommon.currency import CAD
 
 from ..base import TestApp, with_app
     @with_app(do_setup)
     def test_budget(self, app, monkeypatch):
         # when we add a budget, the balance graph will show a regular progression throughout date range
-        patch_today(monkeypatch, 2008, 1, 27)
+        monkeypatch.patch_today(2008, 1, 27)
         app.add_account('expense', account_type=AccountType.Expense)
         app.add_budget('expense', 'Visa', '100')
         app.mw.select_balance_sheet()
     @with_app(do_setup)
     def test_budget_on_last_day_of_the_range(self, app, monkeypatch):
         # don't raise a ZeroDivizionError
-        patch_today(monkeypatch, 2008, 1, 31)
+        monkeypatch.patch_today(2008, 1, 31)
         app.add_account('expense', account_type=AccountType.Expense)
         app.add_budget('expense', 'Visa', '100')
         app.mw.select_balance_sheet()
     @with_app(do_setup)
     def test_budget_with_future_txn(self, app, monkeypatch):
         # when there's a future txn, we want the amount of that txn to be "sharply" displayed
-        patch_today(monkeypatch, 2008, 1, 15)
+        monkeypatch.patch_today(2008, 1, 15)
         app.add_entry('20/1/2008', decrease='10')
         app.add_account('expense', account_type=AccountType.Expense)
         app.add_budget('expense', 'Visa', '100')
 
 class TestBudgetAndNoTranaction:
     def do_setup(self, monkeypatch):
-        patch_today(monkeypatch, 2008, 1, 1)
+        monkeypatch.patch_today(2008, 1, 1)
         app = TestApp()
         app.drsel.select_month_range()
         app.add_account('asset')

core/tests/gui/balance_sheet_test.py

 
 from datetime import date
 
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 from hscommon.currency import Currency, USD, CAD
 
 from ..base import DocumentGUI, ApplicationGUI, TestApp, with_app, testdata
 def test_budget(app, monkeypatch):
     # Account 1 is the target of the expense budget, and Account 2 is the target of the income
     # Assign budgeted amounts to the appropriate accounts.
-    patch_today(monkeypatch, 2008, 1, 15)
+    monkeypatch.patch_today(2008, 1, 15)
     app.add_budget('income', 'Account 2', '400') # + 150
     app.add_budget('expense', 'Account 1', '100') # + 80
     app.mw.select_balance_sheet()
 @with_app(app_accounts_and_entries)
 def test_budget_multiple_currencies(app, monkeypatch):
     # budgeted amounts must be correctly converted to the target's currency
-    patch_today(monkeypatch, 2008, 1, 15)
+    monkeypatch.patch_today(2008, 1, 15)
     USD.set_CAD_value(0.8, date(2008, 1, 1))
     app.mw.select_income_statement()
     app.istatement.selected = app.istatement.income[0]
 @with_app(app_accounts_and_entries)
 def test_budget_target_liability(app, monkeypatch):
     # The budgeted amount must be normalized before being added to a liability amount
-    patch_today(monkeypatch, 2008, 1, 15)
+    monkeypatch.patch_today(2008, 1, 15)
     app.add_account('foo', account_type=AccountType.Liability)
     app.add_budget('income', 'foo', '400')
     app.mainwindow.select_balance_sheet()
 @with_app(app_accounts_and_entries)
 def test_budget_without_target(app, monkeypatch):
     # The Net Worth's "budgeted" column counts all budgets, including target-less ones
-    patch_today(monkeypatch, 2008, 1, 15)
+    monkeypatch.patch_today(2008, 1, 15)
     app.add_budget('income', None, '400')
     app.mw.select_balance_sheet()
     eq_(app.bsheet.net_worth.budgeted, '150.00')

core/tests/gui/bar_graph_test.py

 # which should be included with this package. The terms are also available at 
 # http://www.hardcoded.net/licenses/bsd_license
 
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 from hscommon.currency import CAD
 
 from ..base import TestApp, with_app
 
 class TestSomeIncomeInTheFutureWithRangeOnYearToDate:
     def do_setup(self, monkeypatch):
-        patch_today(monkeypatch, 2010, 1, 12)
+        monkeypatch.patch_today(2010, 1, 12)
         app = TestApp()
         app.add_account('Checking')
         app.mainwindow.show_account()
 
 class TestSomeIncomeTodayAndInTheFuture:
     def do_setup(self, monkeypatch):
-        patch_today(monkeypatch, 2010, 1, 12)
+        monkeypatch.patch_today(2010, 1, 12)
         app = TestApp()
         app.add_account('Checking')
         app.add_account('Income', account_type=AccountType.Income)
         app = TestApp()
         app.drsel.select_month_range()
         app.add_account('Account 1', account_type=AccountType.Income)
-        patch_today(monkeypatch, 2008, 1, 17)
+        monkeypatch.patch_today(2008, 1, 17)
         app.add_budget('Account 1', None, '400')
         app.mainwindow.select_income_statement()
         app.istatement.selected = app.istatement.income[0]
 
 class TestRunningYearWithSomeIncome:
     def do_setup(self, monkeypatch):
-        patch_today(monkeypatch, 2008, 11, 1)
+        monkeypatch.patch_today(2008, 11, 1)
         app = TestApp()
         app.add_account('Checking')
         app.mainwindow.show_account()

core/tests/gui/budget_panel_test.py

 # which should be included with this package. The terms are also available at 
 # http://www.hardcoded.net/licenses/bsd_license
 
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 
 from ...model.account import AccountType
 from ..base import TestApp, with_app
 
 #--- One expense with budget
 def app_one_expense_with_budget(monkeypatch):
-    patch_today(monkeypatch, 2008, 1, 27)
+    monkeypatch.patch_today(2008, 1, 27)
     app = TestApp()
     app.drsel.select_today_date_range()
     app.add_account('Some Expense', account_type=AccountType.Expense)

core/tests/gui/budget_table_test.py

 # which should be included with this package. The terms are also available at 
 # http://www.hardcoded.net/licenses/bsd_license
 
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 
 from ..base import TestApp, with_app
 from ...model.account import AccountType
 
 def app_with_budget(monkeypatch):
     app = TestApp()
-    patch_today(monkeypatch, 2008, 1, 27)
+    monkeypatch.patch_today(2008, 1, 27)
     app.drsel.select_today_date_range()
     app.add_account('Some Expense', account_type=AccountType.Expense)
     app.add_budget('Some Expense', None, '100')

core/tests/gui/date_widget_test.py

 
 from datetime import date
 
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 
 from ...gui.date_widget import DateWidget
 
     
     def test_type_t(self, monkeypatch):
         # Typing 't' sets the date to today
-        patch_today(monkeypatch, 2010, 9, 8)
+        monkeypatch.patch_today(2010, 9, 8)
         self.w.type('t')
         eq_(self.w.text, '08/09/2010')
     
     def test_type_T(self, monkeypatch):
         # The 't' shortcut is case insensitive
-        patch_today(monkeypatch, 2010, 9, 8)
+        monkeypatch.patch_today(2010, 9, 8)
         self.w.type('T')
         eq_(self.w.text, '08/09/2010')
     
     def test_type_t_with_buffer(self, monkeypatch):
         # Typing 't' resets the current buffer
-        patch_today(monkeypatch, 2010, 9, 8)
+        monkeypatch.patch_today(2010, 9, 8)
         self.w.type('1') # buffering mode
         self.w.type('t')
         eq_(self.w.text, '08/09/2010')

core/tests/gui/entry_table_test.py

 # which should be included with this package. The terms are also available at 
 # http://www.hardcoded.net/licenses/bsd_license
 
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 from hscommon.currency import EUR
 
 from ...const import PaneType
 #--- With budget
 def app_with_budget(monkeypatch):
     app = TestApp()
-    patch_today(monkeypatch, 2008, 1, 27)
+    monkeypatch.patch_today(2008, 1, 27)
     app.drsel.select_today_date_range()
     app.add_account('foo', account_type=AccountType.Expense)
     app.add_budget('foo', None, '100')

core/tests/gui/import_window_test.py

 
 from datetime import date
 
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 
 from ..base import TestApp, with_app, DictLoader, testdata
 from ...model.date import YearRange
 
 class TestLoadThemImportWithReference:
     def do_setup(self, monkeypatch):
-        patch_today(monkeypatch, 2008, 1, 1)
+        monkeypatch.patch_today(2008, 1, 1)
         app = TestApp()
         app.doc.load_from_xml(testdata.filepath('moneyguru/with_references1.moneyguru'))
         app.doc.parse_file_for_import(testdata.filepath('moneyguru/with_references2.moneyguru'))

core/tests/gui/income_statement_test.py

 
 from datetime import date
 
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 from hscommon.currency import CAD, USD
 
 from ..base import TestApp, with_app, ApplicationGUI
     @with_app(do_setup)
     def test_attrs_with_budget(self, app, monkeypatch):
         # Must include the budget. 250 of the 400 are spent, there's 150 left to add
-        patch_today(monkeypatch, 2008, 1, 17)
+        monkeypatch.patch_today(2008, 1, 17)
         app.add_budget('Account 1', None, '400')
         app.mainwindow.select_income_statement()
         eq_(app.istatement.income[0].cash_flow, '250.00')
     
     @with_app(do_setup)
     def test_cash_flow_with_underestimated_budget(self, app, monkeypatch):
-        patch_today(monkeypatch, 2008, 1, 17)
+        monkeypatch.patch_today(2008, 1, 17)
         app.add_budget('Account 1', None, '200')
         app.mainwindow.select_income_statement()
         eq_(app.istatement.income[0].cash_flow, '250.00')
     def test_year_to_date_last_cash_flow(self, app, monkeypatch):
         # When the YTD range is selected, the "Last" column shows last year's value (here, 0) instead
         # of showing the exact same thing as this period.
-        patch_today(monkeypatch, 2008, 12, 12)
+        monkeypatch.patch_today(2008, 12, 12)
         app.drsel.select_year_to_date_range()
         eq_(app.istatement.income[0].last_cash_flow, '0.00')
     
     def test_with_budget(self, app, monkeypatch):
         # What this test is making sure of is that the account's budget is of the same currency than
         # the account itself
-        patch_today(monkeypatch, 2008, 1, 20)
+        monkeypatch.patch_today(2008, 1, 20)
         app.add_budget('USD account', None, '300usd')
         app.mainwindow.select_income_statement()
         eq_(app.istatement.income[0][1].cash_flow, 'USD 100.00')
     def test_select_running_year_range(self, app, monkeypatch):
         # the 'Last' column will correctly be set and will include amounts from a whole year before
         # the start of the running year.
-        patch_today(monkeypatch, 2008, 12, 1)
+        monkeypatch.patch_today(2008, 12, 1)
         app.drsel.select_running_year_range()
         # ahead_months is 2, so current is 01/03/2008-28/02/2009, which means 6 + 7 + 8 (21)
         eq_(app.istatement.income[0].cash_flow, '21.00')
 
 class TestBustedBudget:
     def do_setup(self, monkeypatch):
-        patch_today(monkeypatch, 2010, 1, 3)
+        monkeypatch.patch_today(2010, 1, 3)
         app = TestApp()
         app.drsel.select_month_range()
         app.add_account('account', account_type=AccountType.Income)

core/tests/gui/mass_edition_panel_test.py

 # http://www.hardcoded.net/licenses/bsd_license
 
 from pytest import raises
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 
 from ..base import TestApp, with_app
 from ...exception import OperationAborted
 
 def test_attributes(monkeypatch):
     # All fields are disabled and empty.
-    patch_today(monkeypatch, 2010, 2, 20)
+    monkeypatch.patch_today(2010, 2, 20)
     app = app_two_transactions_different_value()
     assert app.mepanel.can_change_accounts
     assert app.mepanel.can_change_amount
 @with_app(app_two_transactions_same_values)
 def test_load_again(app, monkeypatch):
     # load() blanks values when necessary.
-    patch_today(monkeypatch, 2010, 2, 20)
+    monkeypatch.patch_today(2010, 2, 20)
     app.mepanel.date_enabled = True
     app.mepanel.description_enabled = True
     app.mepanel.payee_enabled = True

core/tests/gui/net_worth_graph_test.py

 from datetime import date
 
 from hscommon.currency import CAD, USD
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 
 from ..base import TestApp, with_app, testdata
 from ...model.account import AccountType
     @with_app(do_setup)
     def test_budget(self, app, monkeypatch):
         # when we add a budget, the balance graph will show a regular progression throughout date range
-        patch_today(monkeypatch, 2008, 7, 27)
+        monkeypatch.patch_today(2008, 7, 27)
         app.add_account('income', account_type=AccountType.Income)
         app.add_account('expense', account_type=AccountType.Expense)
         app.add_budget('income', 'asset1', '300')
     @with_app(do_setup)
     def test_budget_target_excluded(self, app, monkeypatch):
         # when the budget target is excluded, don't show it's budgeted data
-        patch_today(monkeypatch, 2008, 7, 27)
+        monkeypatch.patch_today(2008, 7, 27)
         app.add_account('asset3')
         app.add_account('income', account_type=AccountType.Income)
         without_budget = app.nw_graph_data()

core/tests/gui/print_view_test.py

 # which should be included with this package. The terms are also available at 
 # http://www.hardcoded.net/licenses/bsd_license
 
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 
 from ..base import TestApp, with_app
 from ...gui.print_view import PrintView
 
 class TestDateRangeOnApril2009:
     def do_setup(self, monkeypatch):
-        patch_today(monkeypatch, 2009, 4, 1)
+        monkeypatch.patch_today(2009, 4, 1)
         app = TestApp()
         app.drsel.select_month_range()
         app.pv = PrintView(app.tview)

core/tests/gui/profit_graph_test.py

 from datetime import date
 
 from hscommon.currency import USD
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 
 from ..base import TestApp, with_app
 
     @with_app(do_setup)
     def test_budget(self, app, monkeypatch):
         # budgets are counted in the pgraph
-        patch_today(monkeypatch, 2008, 7, 18)
+        monkeypatch.patch_today(2008, 7, 18)
         app.add_budget('income1', 'asset', '400') # +180
         app.mainwindow.select_income_statement()
         amounts = [data[2:] for data in app.pgraph.data]
     @with_app(do_setup)
     def test_budget_and_exclusion(self, app, monkeypatch):
         # when an account is excluded, it's budget is not counted
-        patch_today(monkeypatch, 2008, 7, 18)
+        monkeypatch.patch_today(2008, 7, 18)
         app.add_budget('income1', 'asset', '400') # +180
         app.mainwindow.select_income_statement()
         app.istatement.toggle_excluded()

core/tests/gui/table_sort_test.py

 # which should be included with this package. The terms are also available at 
 # http://www.hardcoded.net/licenses/bsd_license
 
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 
 from ...model.account import AccountType
 from ..base import TestApp, with_app
 #--- Mixed up reconciled schedule and budget
 # A mix of 4 txns. One reconciled, one normal, one schedule spawn and one budget spawn.
 def app_mixed_up_schedule_and_budget(monkeypatch):
-    patch_today(monkeypatch, 2010, 1, 1)
+    monkeypatch.patch_today(2010, 1, 1)
     app = TestApp()
     app.drsel.select_month_range() # we just want 4 transactions
     app.add_account('expense', account_type=AccountType.Expense)

core/tests/gui/transaction_table_test.py

 from datetime import date
 from io import StringIO
 
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 from hscommon.currency import USD
 
 from ..base import TestApp, with_app, testdata
 #--- Transaction on last day of range
 def app_txn_on_last_day_of_range(monkeypatch):
     app = TestApp()
-    patch_today(monkeypatch, 2010, 3, 21)
+    monkeypatch.patch_today(2010, 3, 21)
     app.add_txn('31/12/2010')
     return app
 
 class TestWithBudget:
     def do_setup(self, monkeypatch):
         app = TestApp()
-        patch_today(monkeypatch, 2008, 1, 27)
+        monkeypatch.patch_today(2008, 1, 27)
         app.drsel.select_today_date_range()
         app.add_account('Some Expense', account_type=AccountType.Expense)
         app.add_budget('Some Expense', None, '100')

core/tests/load_test.py

 
 from datetime import date
 
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 from hscommon.currency import PLN, CAD
 
 from ..document import ScheduleScope
 class TestLoadFile:
     # Loads 'simple.moneyguru', a file with 2 accounts and 2 entries in each. Select the first entry.
     def do_setup(self, monkeypatch):
-        patch_today(monkeypatch, 2008, 2, 20) # so that the entries are shown
+        monkeypatch.patch_today(2008, 2, 20) # so that the entries are shown
         app = TestApp()
         app.add_account() # This is to set the modified flag to true so we can make sure it has been put back to false
         app.doc.load_from_xml(testdata.filepath('moneyguru', 'simple.moneyguru'))
 
 class TestLoadImportWithTransactionInTheFuture:
     def do_setup(self, monkeypatch):
-        patch_today(monkeypatch, 2008, 2, 1) # before any txn date
+        monkeypatch.patch_today(2008, 2, 1) # before any txn date
         app = TestApp()
         app.doc.parse_file_for_import(testdata.filepath('moneyguru', 'simple.moneyguru'))
         return app
 class TestLoadWithReferences1:
     def do_setup(self, monkeypatch):
         # Loads 'with_references1.moneyguru' which also have boolean (y/n) reconciliation attributes.
-        patch_today(monkeypatch, 2008, 2, 1) # before any txn date
+        monkeypatch.patch_today(2008, 2, 1) # before any txn date
         app = TestApp()
         app.doc.load_from_xml(testdata.filepath('moneyguru', 'with_references1.moneyguru'))
         return app
     return app
 
 def app_schedule_with_global_change(monkeypatch):
-    patch_today(monkeypatch, 2008, 9, 30)
+    monkeypatch.patch_today(2008, 9, 30)
     app = TestApp()
     app.add_schedule(start_date='13/09/2008', account='account', amount='1', repeat_every=3)
     app.mw.select_transaction_table()
     return app
 
 def app_schedule_with_local_deletion(monkeypatch):
-    patch_today(monkeypatch, 2008, 9, 30)
+    monkeypatch.patch_today(2008, 9, 30)
     app = TestApp()
     app.add_schedule(start_date='13/09/2008', account='account', amount='1', repeat_every=3)
     app.mw.select_transaction_table()

core/tests/main_test.py

 from hscommon import io
 from hscommon.currency import EUR
 from hscommon.path import Path
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 
 from .base import ApplicationGUI, TestApp, with_app, testdata
 from ..app import FIRST_WEEKDAY_PREFERENCE, AHEAD_MONTHS_PREFERENCE
 
 #--- Range on October 2007
 def app_range_on_october2007(monkeypatch):
-    patch_today(monkeypatch, 2007, 10, 1)
+    monkeypatch.patch_today(2007, 10, 1)
     app = TestApp()
     app.drsel.select_month_range()
     return app
 class TestRangeOnYearToDate:
     def do_setup(self, monkeypatch):
         app = TestApp()
-        patch_today(monkeypatch, 2008, 11, 12)
+        monkeypatch.patch_today(2008, 11, 12)
         app.drsel.select_year_to_date_range()
         return app
     
 class TestExampleDocumentLoadTest:
     def do_setup(self, monkeypatch):
         # We're creating a couple of transactions with the latest being 4 months ago (in april).
-        patch_today(monkeypatch, 2009, 8, 27)
+        monkeypatch.patch_today(2009, 8, 27)
         app = TestApp()
         app.add_account()
         app.mw.show_account()

core/tests/model/date_test.py

 from datetime import date
 
 from pytest import raises
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 
 from ...model.date import (parse_date, format_date, clean_format, DateRange, MonthRange,
     QuarterRange, YearRange, RunningYearRange, YearToDateRange)
     def test_running_year(self, monkeypatch):
         # The running year ends at the end of the current month and adds 'ahead_months' to it. the
         # start date is then one year earlier.
-        patch_today(monkeypatch, 2009, 1, 25)
+        monkeypatch.patch_today(2009, 1, 25)
         dr = RunningYearRange(ahead_months=2)
         eq_(dr.end, date(2009, 3, 31))
         eq_(dr.start, date(2008, 4, 1))
         eq_(dr.display, 'Running year (Apr - Mar)')
     
     def test_year_to_date(self, monkeypatch):
-        patch_today(monkeypatch, 2009, 10, 7)
+        monkeypatch.patch_today(2009, 10, 7)
         dr = YearToDateRange(year_start_month=2)
         eq_(dr.display, 'Feb 2009 - Now')
     

core/tests/reconciliation_test.py

 # which should be included with this package. The terms are also available at 
 # http://www.hardcoded.net/licenses/bsd_license
 
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 
 from .base import TestApp, with_app, compare_apps
 from ..model.account import AccountType
 
 #--- Entry in future
 def app_entry_in_future(monkeypatch):
-    patch_today(monkeypatch, 2009, 12, 26)
+    monkeypatch.patch_today(2009, 12, 26)
     app = TestApp()
     app.add_account()
     app.mw.show_account()
 #--- Entry different reconciliation date
 def app_entry_different_reconciliation_date(monkeypatch):
     app = TestApp()
-    patch_today(monkeypatch, 2008, 7, 20)
+    monkeypatch.patch_today(2008, 7, 20)
     app.add_account()
     app.mw.show_account()
     app.add_entry('11/07/2008', decrease='42')

core/tests/recurrence_test.py

 # which should be included with this package. The terms are also available at 
 # http://www.hardcoded.net/licenses/bsd_license
 
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 
 from ..const import PaneType
 from ..document import ScheduleScope
 
 #--- Daily schedule
 def app_daily_schedule(monkeypatch):
-    patch_today(monkeypatch, 2008, 9, 13)
+    monkeypatch.patch_today(2008, 9, 13)
     app = TestApp()
     app.drsel.select_month_range()
     app.add_account('account')
 
 #--- Schedule with local change
 def app_schedule_with_local_change(monkeypatch):
-    patch_today(monkeypatch, 2008, 9, 30)
+    monkeypatch.patch_today(2008, 9, 30)
     app = TestApp()
     app.add_schedule(start_date='13/09/2008', account='account', amount='1', repeat_every=3)
     app.mw.select_transaction_table()
 
 #--- Schedule with global change
 def app_schedule_with_global_change(monkeypatch):
-    patch_today(monkeypatch, 2008, 9, 30)
+    monkeypatch.patch_today(2008, 9, 30)
     app = TestApp()
     app.add_schedule(start_date='13/09/2008', account='account', amount='1', repeat_every=3)
     app.mw.select_transaction_table()
 
 #--- Schedule with local deletion
 def app_schedule_with_local_deletion(monkeypatch):
-    patch_today(monkeypatch, 2008, 9, 30)
+    monkeypatch.patch_today(2008, 9, 30)
     app = TestApp()
     app.add_schedule(start_date='13/09/2008', account='account', amount='1', repeat_every=3)
     app.mw.select_transaction_table()

core/tests/undo_test.py

 import time
 from datetime import date
 
-from hscommon.testutil import eq_, patch_today
+from hscommon.testutil import eq_
 from hscommon.currency import EUR
 
 from ..const import PaneType
 #---
 def app_with_budget(monkeypatch):
     app = TestApp()
-    patch_today(monkeypatch, 2008, 1, 27)
+    monkeypatch.patch_today(2008, 1, 27)
     app.drsel.select_today_date_range()
     app.add_account('Some Expense', account_type=AccountType.Expense)
     app.add_budget('Some Expense', None, '100')
 - sgmllib3k (http://bitbucket.org/hsoft/sgmllib)
 - Sphinx 1.0.6 (http://sphinx.pocoo.org/)
 - pytest 2.0.0, to run unit tests. (http://pytest.org/)
+- pytest-monkeyplus, a pytest plugin. (http://bitbucket.org/hsoft/pytest-monkeyplus)
 
 OS X prerequisites
 ------------------