From 9161506d72e1aaad937f18a79489848eab09d1e4 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Fri, 27 Oct 2023 20:14:17 +0200 Subject: [PATCH] Restore formats registry at the end of test_unknown_format --- tests/test_tablib.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/test_tablib.py b/tests/test_tablib.py index e783d414..47659f84 100755 --- a/tests/test_tablib.py +++ b/tests/test_tablib.py @@ -64,11 +64,15 @@ def test_unknown_format(self): with self.assertRaises(UnsupportedFormat): data.export('??') # A known format but uninstalled - del registry._formats['ods'] - msg = (r"The 'ods' format is not available. You may want to install the " - "odfpy package \\(or `pip install \"tablib\\[ods\\]\"`\\).") - with self.assertRaisesRegex(UnsupportedFormat, msg): - data.export('ods') + saved_registry = registry._formats.copy() + try: + del registry._formats['ods'] + msg = (r"The 'ods' format is not available. You may want to install the " + "odfpy package \\(or `pip install \"tablib\\[ods\\]\"`\\).") + with self.assertRaisesRegex(UnsupportedFormat, msg): + data.export('ods') + finally: + registry._formats = saved_registry def test_empty_append(self): """Verify append() correctly adds tuple with no headers."""