Skip to content
Permalink
Browse files

[FIX] tests: replace deprecated assert aliases

PEP-594 is deprecating a bunch of modules/functions, as part of the
related cleanup, we are also dealing with long-been deprecated
functions.

* `assert_` -> `assertTrue`
* `assertEquals` -> `assertEqual`
* `assertNotEquals` -> `assertNotEqual`
* `assertAlmostEquals` -> `assertAlmostEqual`
* `assertRaisesRegexp` -> `assertRaisesRegex`

Task: 2003936
  • Loading branch information...
Julien00859 committed Sep 9, 2019
1 parent 514f782 commit 84883f8bca1e5ce51a295cfc610ac6d273517631
Showing with 826 additions and 826 deletions.
  1. +9 −9 addons/account/tests/test_account_journal_dashboard.py
  2. +1 −1 addons/account/tests/test_fiscal_position.py
  3. +3 −3 addons/account/tests/test_payment.py
  4. +26 −26 addons/account/tests/test_reconciliation.py
  5. +1 −1 addons/calendar/tests/test_calendar.py
  6. +2 −2 addons/crm/tests/test_crm_pls.py
  7. +2 −2 addons/delivery/tests/test_packing_delivery.py
  8. +11 −11 addons/hr_contract/tests/test_auto_status.py
  9. +39 −39 addons/hr_expense/tests/test_expenses.py
  10. +26 −26 addons/hr_expense/tests/test_expenses_mail_subjects.py
  11. +3 −3 addons/hr_recruitment/tests/test_recruitment_process.py
  12. +19 −19 addons/hr_timesheet/tests/test_timesheet.py
  13. +2 −2 addons/maintenance/tests/test_maintenance.py
  14. +6 −6 addons/maintenance/tests/test_maintenance_multicompany.py
  15. +1 −1 addons/mrp/tests/test_procurement.py
  16. +4 −4 addons/mrp/tests/test_stock.py
  17. +1 −1 addons/mrp/tests/test_warehouse_multistep_manufacturing.py
  18. +6 −6 addons/mrp/tests/test_workorder_operation.py
  19. +2 −2 addons/mrp_account/tests/test_bom_price.py
  20. +34 −34 addons/mrp_subcontracting/tests/test_subcontracting.py
  21. +3 −3 addons/project_timesheet_holidays/tests/test_timesheet_holidays.py
  22. +4 −4 addons/purchase/tests/test_purchase_order_report.py
  23. +19 −19 addons/purchase_mrp/tests/test_purchase_mrp_flow.py
  24. +2 −2 addons/purchase_stock/tests/test_create_picking.py
  25. +7 −7 addons/purchase_stock/tests/test_fifo_price.py
  26. +1 −1 addons/purchase_stock/tests/test_move_cancel_propagation.py
  27. +4 −4 addons/purchase_stock/tests/test_onchange_product.py
  28. +28 −28 addons/purchase_stock/tests/test_stockvaluation.py
  29. +1 −1 addons/sale/tests/test_access_rights.py
  30. +3 −3 addons/sale/tests/test_onchange.py
  31. +25 −25 addons/sale/tests/test_reinvoice.py
  32. +5 −5 addons/sale/tests/test_sale_order.py
  33. +9 −9 addons/sale/tests/test_sale_pricelist.py
  34. +111 −111 addons/sale/tests/test_sale_refund.py
  35. +38 −38 addons/sale/tests/test_sale_to_invoice.py
  36. +27 −27 addons/sale_expense/tests/test_reinvoice.py
  37. +60 −60 addons/sale_mrp/tests/test_sale_mrp_flow.py
  38. +3 −3 addons/sale_stock/tests/test_sale_order_dates.py
  39. +6 −6 addons/sale_stock/tests/test_sale_stock.py
  40. +4 −4 addons/sale_stock/tests/test_sale_stock_lead_time.py
  41. +1 −1 addons/sale_timesheet/tests/test_project_billing.py
  42. +29 −29 addons/sale_timesheet/tests/test_reinvoice.py
  43. +20 −20 addons/stock/tests/test_move2.py
  44. +14 −14 addons/stock/tests/test_packing.py
  45. +7 −7 addons/stock/tests/test_proc_rule.py
  46. +18 −18 addons/stock/tests/test_stock_flow.py
  47. +2 −2 addons/stock/tests/test_stock_location_search.py
  48. +3 −3 addons/stock_dropshipping/tests/test_dropship.py
  49. +19 −19 addons/survey/tests/test_certification_badge.py
  50. +2 −2 addons/test_mail/tests/test_mail_resend.py
  51. +12 −12 addons/test_website/tests/test_controller_args.py
  52. +2 −2 addons/test_website/tests/test_views_during_module_operation.py
  53. +5 −5 addons/uom/tests/test_uom.py
  54. +1 −1 addons/website_mail_channel/tests/test_unsubscribe.py
  55. +3 −3 addons/website_sale/tests/test_website_sale_pricelist.py
  56. +3 −3 addons/website_sale_comparison/tests/test_website_sale_comparison.py
  57. +6 −6 addons/website_theme_install/tests/test_views.py
  58. +7 −7 odoo/addons/base/tests/test_acl.py
  59. +9 −9 odoo/addons/base/tests/test_base.py
  60. +1 −1 odoo/addons/base/tests/test_basecase.py
  61. +1 −1 odoo/addons/base/tests/test_mail.py
  62. +6 −6 odoo/addons/base/tests/test_osv.py
  63. +2 −2 odoo/addons/base/tests/test_qweb.py
  64. +11 −11 odoo/addons/base/tests/test_res_partner_bank.py
  65. +20 −20 odoo/addons/base/tests/test_translate.py
  66. +62 −62 odoo/addons/test_assetsbundle/tests/test_assetsbundle.py
  67. +1 −1 odoo/addons/test_performance/tests/test_performance.py
  68. +1 −1 odoo/addons/test_testing_utilities/tests/test_form_impl.py
@@ -49,30 +49,30 @@ def patched_today(*args, **kwargs):
# Check Draft
dashboard_data = journal.get_journal_dashboard_datas()

self.assertEquals(dashboard_data['number_draft'], 2)
self.assertEqual(dashboard_data['number_draft'], 2)
self.assertIn('68.42', dashboard_data['sum_draft'])

self.assertEquals(dashboard_data['number_waiting'], 0)
self.assertEqual(dashboard_data['number_waiting'], 0)
self.assertIn('0.00', dashboard_data['sum_waiting'])

# Check Both
invoice.post()

dashboard_data = journal.get_journal_dashboard_datas()
self.assertEquals(dashboard_data['number_draft'], 1)
self.assertEqual(dashboard_data['number_draft'], 1)
self.assertIn('-13.30', dashboard_data['sum_draft'])

self.assertEquals(dashboard_data['number_waiting'], 1)
self.assertEqual(dashboard_data['number_waiting'], 1)
self.assertIn('81.72', dashboard_data['sum_waiting'])

# Check waiting payment
refund.post()

dashboard_data = journal.get_journal_dashboard_datas()
self.assertEquals(dashboard_data['number_draft'], 0)
self.assertEqual(dashboard_data['number_draft'], 0)
self.assertIn('0.00', dashboard_data['sum_draft'])

self.assertEquals(dashboard_data['number_waiting'], 2)
self.assertEqual(dashboard_data['number_waiting'], 2)
self.assertIn('68.42', dashboard_data['sum_waiting'])

# Check partial
@@ -96,13 +96,13 @@ def patched_today(*args, **kwargs):
refund.js_assign_outstanding_line(payment_move_line.id)

dashboard_data = journal.get_journal_dashboard_datas()
self.assertEquals(dashboard_data['number_draft'], 0)
self.assertEqual(dashboard_data['number_draft'], 0)
self.assertIn('0.00', dashboard_data['sum_draft'])

self.assertEquals(dashboard_data['number_waiting'], 2)
self.assertEqual(dashboard_data['number_waiting'], 2)
self.assertIn('78.42', dashboard_data['sum_waiting'])

with patch('odoo.fields.Date.today', patched_today):
dashboard_data = journal.get_journal_dashboard_datas()
self.assertEquals(dashboard_data['number_late'], 2)
self.assertEqual(dashboard_data['number_late'], 2)
self.assertIn('78.42', dashboard_data['sum_late'])
@@ -58,7 +58,7 @@ def setUp(self):

def test_10_fp_country(self):
def assert_fp(partner, expected_pos, message):
self.assertEquals(
self.assertEqual(
self.fp.get_fiscal_position(partner.id),
expected_pos.id,
message)
@@ -88,7 +88,7 @@ def test_full_payment_process(self):
})
payment = self.payment_model.browse(register_payments.create_payments()['res_id'])

self.assertAlmostEquals(payment.amount, 300)
self.assertAlmostEqual(payment.amount, 300)
self.assertEqual(payment.state, 'posted')
self.assertEqual(payment.state, 'posted')
self.assertEqual(inv_1.invoice_payment_state, 'paid')
@@ -161,7 +161,7 @@ def test_partial_payment(self):

self.assertEqual(len(payment), 1)
self.assertEqual(payment.invoice_ids[0].id, inv_1.id)
self.assertAlmostEquals(payment.amount, 550)
self.assertAlmostEqual(payment.amount, 550)
self.assertEqual(payment.payment_type, 'inbound')
self.assertEqual(payment.partner_id, self.partner_agrolait)
self.assertEqual(payment.partner_type, 'customer')
@@ -180,7 +180,7 @@ def test_partial_payment(self):

self.assertEqual(len(payment), 1)
self.assertEqual(payment.invoice_ids[0].id, inv_2.id)
self.assertAlmostEquals(payment.amount, 300)
self.assertAlmostEqual(payment.amount, 300)
self.assertEqual(payment.payment_type, 'outbound')
self.assertEqual(payment.partner_id, self.partner_china_exp)
self.assertEqual(payment.partner_type, 'supplier')
@@ -352,11 +352,11 @@ def test_statement_euro_invoice_usd_transaction_euro_full(self):
])

# The invoice should be paid, as the payments totally cover its total
self.assertEquals(move.invoice_payment_state, 'paid', 'The invoice should be paid by now')
self.assertEqual(move.invoice_payment_state, 'paid', 'The invoice should be paid by now')
self.assertTrue(receivable_line.reconciled, 'The invoice should be totally reconciled')
self.assertTrue(receivable_line.full_reconcile_id, 'The invoice should have a full reconcile number')
self.assertEquals(receivable_line.amount_residual, 0, 'The invoice should be totally reconciled')
self.assertEquals(receivable_line.amount_residual_currency, 0, 'The invoice should be totally reconciled')
self.assertEqual(receivable_line.amount_residual, 0, 'The invoice should be totally reconciled')
self.assertEqual(receivable_line.amount_residual_currency, 0, 'The invoice should be totally reconciled')

@unittest.skip('adapt to new accounting')
def test_balanced_exchanges_gain_loss(self):
@@ -422,7 +422,7 @@ def test_balanced_exchanges_gain_loss(self):
])

# The invoice should be paid, as the payments totally cover its total
self.assertEquals(invoice.state, 'paid', 'The invoice should be paid by now')
self.assertEqual(invoice.state, 'paid', 'The invoice should be paid by now')
reconcile = None
for payment in invoice.payment_ids:
reconcile = payment.reconcile_model_id
@@ -442,8 +442,8 @@ def test_balanced_exchanges_gain_loss(self):
self.assertTrue(exchange_loss_line, 'There should be one move line of 0.01 EUR in credit')
# The journal items of the reconciliation should have their debit and credit total equal
# Besides, the total debit and total credit should be 60.61 EUR (2.00 USD)
self.assertEquals(sum(res['debit'] for res in result.values()), 60.61)
self.assertEquals(sum(res['credit'] for res in result.items()), 60.61)
self.assertEqual(sum(res['debit'] for res in result.values()), 60.61)
self.assertEqual(sum(res['credit'] for res in result.items()), 60.61)
counterpart_exchange_loss_line = None
for line in exchange_loss_line.move_id.line_id:
if line.account_id.id == self.account_fx_expense_id:
@@ -487,8 +487,8 @@ def create_move(name, amount, amount_currency, currency_id):
aml_recs.reconcile()
for aml in aml_recs:
self.assertTrue(aml.reconciled, 'The journal item should be totally reconciled')
self.assertEquals(aml.amount_residual, 0, 'The journal item should be totally reconciled')
self.assertEquals(aml.amount_residual_currency, 0, 'The journal item should be totally reconciled')
self.assertEqual(aml.amount_residual, 0, 'The journal item should be totally reconciled')
self.assertEqual(aml.amount_residual_currency, 0, 'The journal item should be totally reconciled')

move_list_vals = [
('2', 728.35, 795.05, self.currency_swiss_id),
@@ -504,8 +504,8 @@ def create_move(name, amount, amount_currency, currency_id):
aml_recs.reconcile(self.account_rsa, self.bank_journal_usd)
for aml in aml_recs:
self.assertTrue(aml.reconciled, 'The journal item should be totally reconciled')
self.assertEquals(aml.amount_residual, 0, 'The journal item should be totally reconciled')
self.assertEquals(aml.amount_residual_currency, 0, 'The journal item should be totally reconciled')
self.assertEqual(aml.amount_residual, 0, 'The journal item should be totally reconciled')
self.assertEqual(aml.amount_residual_currency, 0, 'The journal item should be totally reconciled')

def test_manual_reconcile_wizard_same_account(self):
move_ids = self.env['account.move']
@@ -564,7 +564,7 @@ def test_manual_reconcile_wizard_same_account(self):
}]
writeoff_line = account_move_line._create_writeoff(writeoff_vals)
(account_move_line + writeoff_line).reconcile()
self.assertEquals(len(writeoff_line), 1, "The writeoff_line (balance_line) should have only one moves line")
self.assertEqual(len(writeoff_line), 1, "The writeoff_line (balance_line) should have only one moves line")
self.assertTrue(all(l.reconciled for l in writeoff_line), 'The balance lines should be totally reconciled')
self.assertTrue(all(l.reconciled for l in account_move_line), 'The move lines should be totally reconciled')

@@ -612,7 +612,7 @@ def test_reconcile_bank_statement_with_payment_and_writeoff(self):
# Check that move lines associated to bank_statement are correct
bank_stmt_aml = self.env['account.move.line'].search([('statement_id', '=', bank_stmt.id)])
bank_stmt_aml |= bank_stmt_aml.mapped('move_id').mapped('line_ids')
self.assertEquals(len(bank_stmt_aml), 4, "The bank statement should have 4 moves lines")
self.assertEqual(len(bank_stmt_aml), 4, "The bank statement should have 4 moves lines")
lines = {
self.account_usd.id: [
{'debit': 3.27, 'credit': 0.0, 'amount_currency': 5, 'currency_id': self.currency_usd_id},
@@ -637,10 +637,10 @@ def test_reconcile_bank_statement_with_payment_and_writeoff(self):
line = line[0]
else:
line = line[1]
self.assertEquals(round(aml.debit, 2), line['debit'])
self.assertEquals(round(aml.credit, 2), line['credit'])
self.assertEquals(round(aml.amount_currency, 2), line['amount_currency'])
self.assertEquals(aml.currency_id.id, line['currency_id'])
self.assertEqual(round(aml.debit, 2), line['debit'])
self.assertEqual(round(aml.credit, 2), line['credit'])
self.assertEqual(round(aml.amount_currency, 2), line['amount_currency'])
self.assertEqual(aml.currency_id.id, line['currency_id'])

def test_partial_reconcile_currencies_01(self):
# client Account (payable, rsa)
@@ -791,19 +791,19 @@ def test_unreconcile(self):
credit_aml = payment.move_line_ids.filtered('credit')

# Check residual before assignation
self.assertAlmostEquals(inv1.amount_residual, 10)
self.assertAlmostEquals(inv2.amount_residual, 20)
self.assertAlmostEqual(inv1.amount_residual, 10)
self.assertAlmostEqual(inv2.amount_residual, 20)

# Assign credit and residual
inv1.js_assign_outstanding_line(credit_aml.id)
inv2.js_assign_outstanding_line(credit_aml.id)
self.assertAlmostEquals(inv1.amount_residual, 0)
self.assertAlmostEquals(inv2.amount_residual, 0)
self.assertAlmostEqual(inv1.amount_residual, 0)
self.assertAlmostEqual(inv2.amount_residual, 0)

# Unreconcile one invoice at a time and check residual
credit_aml.remove_move_reconcile()
self.assertAlmostEquals(inv1.amount_residual, 10)
self.assertAlmostEquals(inv2.amount_residual, 20)
self.assertAlmostEqual(inv1.amount_residual, 10)
self.assertAlmostEqual(inv2.amount_residual, 20)

def test_unreconcile_exchange(self):
# Use case:
@@ -842,16 +842,16 @@ def test_unreconcile_exchange(self):
credit_aml = payment.move_line_ids.filtered('credit')

# Check residual before assignation
self.assertAlmostEquals(inv.amount_residual, 111)
self.assertAlmostEqual(inv.amount_residual, 111)

# Assign credit, check exchange move and residual
inv.js_assign_outstanding_line(credit_aml.id)
self.assertEqual(len(payment.move_line_ids.mapped('full_reconcile_id').exchange_move_id), 1)
self.assertAlmostEquals(inv.amount_residual, 0)
self.assertAlmostEqual(inv.amount_residual, 0)

# Unreconcile invoice and check residual
credit_aml.with_context(invoice_id=inv.id).remove_move_reconcile()
self.assertAlmostEquals(inv.amount_residual, 111)
self.assertAlmostEqual(inv.amount_residual, 111)

def test_revert_payment_and_reconcile(self):
payment = self.env['account.payment'].create({
@@ -2081,4 +2081,4 @@ def test_reconciliation_process_move_lines_with_mixed_currencies(self):
}])

writeoff_line = self.env['account.move.line'].search([('name', '=', 'writeoff')])
self.assertEquals(writeoff_line.credit, 15.0)
self.assertEqual(writeoff_line.credit, 15.0)
@@ -158,7 +158,7 @@ def test_validation_error(self):
(str(m.start_datetime), str(m.stop_datetime)),
('2017-07-12 14:30:00', u'2017-07-12 15:00:00'),
)
self.assertEquals(
self.assertEqual(
(str(records.start_datetime), str(records.stop_datetime)),
(u'2017-07-10 15:30:00', u'2017-07-10 16:00:00'),
)
@@ -78,5 +78,5 @@ def test_predictive_lead_scoring(self):
# As the cron is computing and writing in SQL queries, we need to invalidate the cache
leads.invalidate_cache()

self.assertEquals(tools.float_compare(leads[3].automated_probability, 33.49, 2), 0)
self.assertEquals(tools.float_compare(leads[7].automated_probability, 7.74, 2), 0)
self.assertEqual(tools.float_compare(leads[3].automated_probability, 33.49, 2), 0)
self.assertEqual(tools.float_compare(leads[7].automated_probability, 7.74, 2), 0)
@@ -66,9 +66,9 @@ def test_put_in_pack_weight_wizard(self):
pack_action_model = pack_action['res_model']

# We make sure the correct action was returned
self.assertEquals(pack_action_model, 'choose.delivery.package')
self.assertEqual(pack_action_model, 'choose.delivery.package')

# We instanciate the wizard with the context of the action and check that the
# default weight was set.
pack_wiz = self.env['choose.delivery.package'].with_context(pack_action_ctx).create({})
self.assertEquals(pack_wiz.shipping_weight, 13.5)
self.assertEqual(pack_wiz.shipping_weight, 13.5)
@@ -13,7 +13,7 @@ def setUp(self):
self.test_contract = dict(name='Test', wage=1, employee_id=self.employee.id, state='open')

def test_employee_contractwarning(self):
self.assertEquals(self.employee.contract_warning, True)
self.assertEqual(self.employee.contract_warning, True)

def apply_cron(self):
self.env.ref('hr_contract.ir_cron_data_contract_update_state').method_direct_trigger()
@@ -22,15 +22,15 @@ def test_contract_enddate(self):
self.test_contract.update(dict(date_end=datetime.now() + relativedelta(days=100)))
self.contract = self.contracts.create(self.test_contract)
self.apply_cron()
self.assertEquals(self.contract.state, 'open')
self.assertEquals(self.contract.kanban_state, 'normal')
self.assertEquals(self.employee.contract_warning, False)
self.assertEqual(self.contract.state, 'open')
self.assertEqual(self.contract.kanban_state, 'normal')
self.assertEqual(self.employee.contract_warning, False)

self.test_contract.update(dict(date_end=datetime.now() + relativedelta(days=5)))
self.contract.write(self.test_contract)
self.apply_cron()
self.assertEquals(self.contract.state, 'open')
self.assertEquals(self.contract.kanban_state, 'blocked')
self.assertEqual(self.contract.state, 'open')
self.assertEqual(self.contract.kanban_state, 'blocked')

self.test_contract.update({
'date_start': datetime.now() + relativedelta(days=-50),
@@ -40,15 +40,15 @@ def test_contract_enddate(self):
})
self.contract.write(self.test_contract)
self.apply_cron()
self.assertEquals(self.contract.state, 'close')
self.assertEqual(self.contract.state, 'close')

def test_contract_pending_visa_expire(self):
self.employee.visa_expire = date.today() + relativedelta(days=30)
self.test_contract.update(dict(date_end=False))
self.contract = self.contracts.create(self.test_contract)
self.apply_cron()
self.assertEquals(self.contract.state, 'open')
self.assertEquals(self.contract.kanban_state, 'blocked')
self.assertEqual(self.contract.state, 'open')
self.assertEqual(self.contract.kanban_state, 'blocked')

self.employee.visa_expire = date.today() + relativedelta(days=-5)
self.test_contract.update({
@@ -58,10 +58,10 @@ def test_contract_pending_visa_expire(self):
})
self.contract.write(self.test_contract)
self.apply_cron()
self.assertEquals(self.contract.state, 'close')
self.assertEqual(self.contract.state, 'close')

def test_contract_start_date(self):
self.test_contract.update(dict(date_start=datetime.now(), state='draft', kanban_state='done'))
self.contract = self.contracts.create(self.test_contract)
self.apply_cron()
self.assertEquals(self.contract.state, 'open')
self.assertEqual(self.contract.state, 'open')

0 comments on commit 84883f8

Please sign in to comment.
You can’t perform that action at this time.