Skip to content

Commit

Permalink
Restore formats registry at the end of test_unknown_format
Browse files Browse the repository at this point in the history
  • Loading branch information
claudep committed Oct 27, 2023
1 parent 0f0ddf6 commit dc23c4c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/test_tablib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down

0 comments on commit dc23c4c

Please sign in to comment.