Commit a0021640 authored by Carlos Ramos Carreño's avatar Carlos Ramos Carreño

Fix id tool tests.

Some tests were added to check warnings, which were not working in
Python 2 because the warning message was shown just once.
This is fixed by adding a `warnings.simplefilter("always")` inside
the `catch_warnings` context manager, as recommended in
https://docs.python.org/3/library/warnings.html#testing-warnings .
Note that the previous filter is restored on leaving the context
manager.
parent 72155b6c
......@@ -151,6 +151,7 @@ class TestIdTool(ERP5TypeTestCase):
# generateNewId expect str, but convert id_group when passed a wrong type
with warnings.catch_warnings(record=True) as recorded:
warnings.simplefilter("always")
self.assertEqual(
self.id_tool.generateNewId(
id_generator=id_generator,
......@@ -168,6 +169,7 @@ class TestIdTool(ERP5TypeTestCase):
id_group='bytes',
), 0)
with warnings.catch_warnings(record=True) as recorded:
warnings.simplefilter("always")
self.assertEqual(
self.id_tool.generateNewId(
id_generator=id_generator,
......@@ -269,6 +271,7 @@ class TestIdTool(ERP5TypeTestCase):
# generateNewIdList expect str, but convert id_group when passed a wrong type
with warnings.catch_warnings(record=True) as recorded:
warnings.simplefilter("always")
self.assertEqual(
self.id_tool.generateNewIdList(
id_generator=id_generator,
......@@ -287,6 +290,7 @@ class TestIdTool(ERP5TypeTestCase):
id_count=1,
), [0])
with warnings.catch_warnings(record=True) as recorded:
warnings.simplefilter("always")
self.assertEqual(
self.id_tool.generateNewIdList(
id_generator=id_generator,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment