Skip to content

Commit

Permalink
[FIX] point_of_sale: fix syntax error in with statements
Browse files Browse the repository at this point in the history
Python3.7 and 3.8 do not support this syntax.
See: python/peps#2244
  • Loading branch information
aj-fuentes committed Jan 22, 2024
1 parent e0ebcff commit 7bdc9e2
Showing 1 changed file with 18 additions and 30 deletions.
48 changes: 18 additions & 30 deletions addons/point_of_sale/tests/test_pos_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,9 @@ def test_capture_one_order(self):
orders = [self.create_ui_order_data([(self.product1, 1)])]

self.assert_activity_and_attachment(session, 0)
with (
patch.object(PosOrder, '_process_order', mocked_process_order),
patch.object(PosSession, '_handle_order_process_fail', mocked_handle_order_process_fail),
self.assertLogs('odoo.addons.point_of_sale.models.pos_order', level=logging.ERROR) as logger_error_output
):
with patch.object(PosOrder, '_process_order', mocked_process_order),\
patch.object(PosSession, '_handle_order_process_fail', mocked_handle_order_process_fail),\
self.assertLogs('odoo.addons.point_of_sale.models.pos_order', level=logging.ERROR) as logger_error_output:
try:
self.env['pos.order'].create_from_ui(orders)
except IntendedException:
Expand All @@ -69,11 +67,9 @@ def test_capture_two_orders(self):
order1 = [self.create_ui_order_data([(self.product1, 1)], uid='12345-678-1996')]
order2 = [self.create_ui_order_data([(self.product1, 1)], uid='12345-678-1999')] # Different order with same content but different uuid

with (
patch.object(PosOrder, '_process_order', mocked_process_order),
patch.object(PosSession, '_handle_order_process_fail', mocked_handle_order_process_fail),
self.assertLogs('odoo.addons.point_of_sale.models.pos_order', level=logging.ERROR)
):
with patch.object(PosOrder, '_process_order', mocked_process_order),\
patch.object(PosSession, '_handle_order_process_fail', mocked_handle_order_process_fail),\
self.assertLogs('odoo.addons.point_of_sale.models.pos_order', level=logging.ERROR):
try:
self.env['pos.order'].create_from_ui(order1)
except IntendedException:
Expand All @@ -92,11 +88,9 @@ def test_capture_one_order_twice(self):
orders = [self.create_ui_order_data([(self.product1, 1)])]

self.assert_activity_and_attachment(session, 0)
with (
patch.object(PosOrder, '_process_order', mocked_process_order),
patch.object(PosSession, '_handle_order_process_fail', mocked_handle_order_process_fail),
self.assertLogs('odoo.addons.point_of_sale.models.pos_order', level=logging.ERROR)
):
with patch.object(PosOrder, '_process_order', mocked_process_order),\
patch.object(PosSession, '_handle_order_process_fail', mocked_handle_order_process_fail),\
self.assertLogs('odoo.addons.point_of_sale.models.pos_order', level=logging.ERROR):
for _ in range(2):
try:
self.env['pos.order'].create_from_ui(orders)
Expand All @@ -112,11 +106,9 @@ def test_capture_order_same_uuid(self):
order2 = [self.create_ui_order_data([(self.product1, 2)], uid='12345-678-1996')]

self.assert_activity_and_attachment(session, 0)
with (
patch.object(PosOrder, '_process_order', mocked_process_order),
patch.object(PosSession, '_handle_order_process_fail', mocked_handle_order_process_fail),
self.assertLogs('odoo.addons.point_of_sale.models.pos_order', level=logging.ERROR)
):
with patch.object(PosOrder, '_process_order', mocked_process_order),\
patch.object(PosSession, '_handle_order_process_fail', mocked_handle_order_process_fail),\
self.assertLogs('odoo.addons.point_of_sale.models.pos_order', level=logging.ERROR):
try:
self.env['pos.order'].create_from_ui(order1)
except IntendedException:
Expand All @@ -135,11 +127,9 @@ def test_capture_one_order_and_removed(self):
orders = [self.create_ui_order_data([(self.product1, 1)])]

self.assert_activity_and_attachment(session, 0)
with (
patch.object(PosOrder, '_process_order', mocked_process_order),
patch.object(PosSession, '_handle_order_process_fail', mocked_handle_order_process_fail),
self.assertLogs('odoo.addons.point_of_sale.models.pos_order', level=logging.ERROR)
):
with patch.object(PosOrder, '_process_order', mocked_process_order),\
patch.object(PosSession, '_handle_order_process_fail', mocked_handle_order_process_fail),\
self.assertLogs('odoo.addons.point_of_sale.models.pos_order', level=logging.ERROR):
try:
self.env['pos.order'].create_from_ui(orders)
except IntendedException:
Expand All @@ -159,11 +149,9 @@ def test_capture_two_orders_and_removed(self):
order1 = [self.create_ui_order_data([(self.product1, 1)], uid='12345-678-1996')]
order2 = [self.create_ui_order_data([(self.product1, 1)], uid='12345-678-1999')] # Different order with same content but different uuid

with (
patch.object(PosOrder, '_process_order', mocked_process_order),
patch.object(PosSession, '_handle_order_process_fail', mocked_handle_order_process_fail),
self.assertLogs('odoo.addons.point_of_sale.models.pos_order', level=logging.ERROR)
):
with patch.object(PosOrder, '_process_order', mocked_process_order),\
patch.object(PosSession, '_handle_order_process_fail', mocked_handle_order_process_fail),\
self.assertLogs('odoo.addons.point_of_sale.models.pos_order', level=logging.ERROR):
try:
self.env['pos.order'].create_from_ui(order1)
except IntendedException:
Expand Down

0 comments on commit 7bdc9e2

Please sign in to comment.