From 42b597b2bd3aa9dc8b892e7af699dd6e77827289 Mon Sep 17 00:00:00 2001 From: Jacques-Etienne Baudoux Date: Fri, 6 Dec 2024 12:20:55 +0100 Subject: [PATCH] printing_auto_stock_picking: fix tests --- .../tests/test_printing_auto_stock.py | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/printing_auto_stock_picking/tests/test_printing_auto_stock.py b/printing_auto_stock_picking/tests/test_printing_auto_stock.py index 325a1a58d57..a6f4f06a890 100644 --- a/printing_auto_stock_picking/tests/test_printing_auto_stock.py +++ b/printing_auto_stock_picking/tests/test_printing_auto_stock.py @@ -2,7 +2,6 @@ # Copyright 2022 Michael Tietz (MT Software) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -import logging from unittest import mock from odoo.exceptions import UserError @@ -14,31 +13,27 @@ ) -def exception(*args, **kwargs): - return - - @mock.patch.object(PrintingPrinter, "print_document", print_document) -@mock.patch.object(logging.Logger, "exception", exception) class TestAutoPrinting(TestPrintingAutoCommon): @classmethod def setUpReportAndRecord(cls): cls.report = cls.env.ref("stock.action_report_delivery") cls.record = cls.env.ref("stock.outgoing_shipment_main_warehouse") - @classmethod - def setUpClass(cls): - super().setUpClass() - cls.printing_auto = cls._create_printing_auto_attachment() - cls._create_attachment(cls.record, cls.data, "1") - cls.record.picking_type_id.auto_printing_ids |= cls.printing_auto + def setUp(self): + # Note: Using setUpClass, cls.record.picking_type_id.auto_printing_ids + # is reset on each test making them fail + super().setUp() + self.printing_auto = self._create_printing_auto_attachment() + self._create_attachment(self.record, self.data, "1") + self.record.picking_type_id.auto_printing_ids |= self.printing_auto def test_action_done_printing_auto(self): self.printing_auto.printer_id = self.printer_1 self.record._action_done() self.assertFalse(self.record.printing_auto_error) - def test_action_done_printing_error(self): + def test_action_done_printing_error_log(self): self.record._action_done() self.assertTrue(self.record.printing_auto_error)