|
4 | 4 |
|
5 | 5 | from .common import TestMTOVariantCommon |
6 | 6 |
|
| 7 | +_logger = logging.getLogger(__name__) |
| 8 | + |
7 | 9 |
|
8 | 10 | class TestMTOVariant(TestMTOVariantCommon): |
9 | 11 | def test_variants_mto(self): |
@@ -65,43 +67,49 @@ def test_template_warnings(self): |
65 | 67 | red_pen = self.red_pen |
66 | 68 | green_pen = self.green_pen |
67 | 69 | black_pen = self.black_pen |
68 | | - onchange_logger = logging.getLogger("odoo.tests.common.onchange") |
69 | 70 | self.assertVariantsNotMTO(pens) |
| 71 | + |
70 | 72 | # enable mto route for black pen |
71 | 73 | self.toggle_is_mto(black_pen) |
72 | 74 | self.assertVariantsMTO(black_pen) |
| 75 | + |
73 | 76 | # Enable mto route on the template, raise warning as is_mto is reset on variants |
74 | | - with self.assertLogs(onchange_logger) as log: |
| 77 | + with self.assertLogs(level="WARNING") as log_catcher: |
75 | 78 | self.add_route(pen_template, self.mto_route) |
76 | | - self.assertIn("WARNING", log.output[0]) |
77 | | - self.assertIn("Activating MTO route will reset", log.output[0]) |
| 79 | + self.assertIn("WARNING", log_catcher.output[0]) |
| 80 | + self.assertIn("Activating MTO route will reset", log_catcher.output[0]) |
78 | 81 | self.assertVariantsMTO(pens) |
| 82 | + |
79 | 83 | # Disable mto route for black pen |
80 | 84 | self.toggle_is_mto(black_pen) |
81 | 85 | self.assertVariantsNotMTO(black_pen) |
82 | 86 | self.assertVariantsMTO(blue_pen | green_pen | red_pen) |
| 87 | + |
83 | 88 | # Enable unrelated route does not raise warning nor reset |
84 | 89 | random_route = self.mto_route.create({"name": "loutourout de la vit"}) |
85 | | - with self.assertLogs(onchange_logger) as log: |
| 90 | + with self.assertLogs() as log_catcher: |
86 | 91 | self.add_route(pen_template, random_route) |
87 | | - onchange_logger.info("No warning raised") |
88 | | - self.assertNotIn("WARNING", log.output[0]) |
| 92 | + _logger.info("No warning raised") |
| 93 | + self.assertNotIn("WARNING", log_catcher.output[0]) |
89 | 94 | self.assertVariantsNotMTO(black_pen) |
90 | 95 | self.assertVariantsMTO(blue_pen | green_pen | red_pen) |
91 | | - # Disable mto route on the template, raise warning as is_mto is reset on variants |
92 | | - with self.assertLogs(onchange_logger) as log: |
| 96 | + |
| 97 | + # Disable mto route on the template, |
| 98 | + # raise warning as is_mto is reset on variants |
| 99 | + with self.assertLogs() as log_catcher: |
93 | 100 | self.remove_route(pen_template, self.mto_route) |
94 | | - self.assertIn("WARNING", log.output[0]) |
95 | | - self.assertIn("Deactivating MTO route will reset", log.output[0]) |
| 101 | + self.assertIn("WARNING", log_catcher.output[0]) |
| 102 | + self.assertIn("Deactivating MTO route will reset", log_catcher.output[0]) |
96 | 103 | self.assertVariantsNotMTO(pens) |
| 104 | + |
97 | 105 | # Enable mto route for black pen |
98 | 106 | self.toggle_is_mto(black_pen) |
99 | 107 | self.assertVariantsMTO(black_pen) |
100 | 108 | self.assertVariantsNotMTO(blue_pen | green_pen | red_pen) |
| 109 | + |
101 | 110 | # Disable unrelated route does not raise warning nor reset |
102 | | - with self.assertLogs(onchange_logger) as log: |
| 111 | + with self.assertLogs() as log_catcher: |
103 | 112 | self.remove_route(pen_template, random_route) |
104 | | - onchange_logger.info("No warning raised") |
105 | | - self.assertNotIn("WARNING", log.output[0]) |
| 113 | + _logger.info("No warning raised") |
106 | 114 | self.assertVariantsMTO(black_pen) |
107 | 115 | self.assertVariantsNotMTO(blue_pen | green_pen | red_pen) |
0 commit comments