From 8a6e3087ce38fa09751930d1a6cca1a40e875c6c Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Wed, 17 Mar 2021 11:55:51 +0000 Subject: [PATCH] Use pytest exception handling --- Tests/varLib/varLib_test.py | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/Tests/varLib/varLib_test.py b/Tests/varLib/varLib_test.py index 76d951def..2a4cff767 100644 --- a/Tests/varLib/varLib_test.py +++ b/Tests/varLib/varLib_test.py @@ -814,16 +814,9 @@ class BuildTest(unittest.TestCase): assert ds_loaded.instances[0].location == {"weight": 0, "width": 50} def test_varlib_build_incompatible_features(self): - try: - self._run_varlib_build_test( - designspace_name="IncompatibleFeatures", - font_name="IncompatibleFeatures", - tables=["GPOS"], - expected_ttx_name="IncompatibleFeatures", - save_before_dump=True, - ) - except VarLibMergeError as e: - assert str(e) == """ + with pytest.raises( + VarLibMergeError, + match = """ Couldn't merge the fonts, because some values were different, but should have been the same. This happened while performing the following operation: @@ -834,11 +827,16 @@ The problem is likely to be in Simple Two Axis Bold: Incompatible features between masters. Expected: kern, mark. Got: kern. -""" - except Exception: - self.fail('unexpected exception raised') - else: - self.fail('ExpectedException not raised') +"""): + + self._run_varlib_build_test( + designspace_name="IncompatibleFeatures", + font_name="IncompatibleFeatures", + tables=["GPOS"], + expected_ttx_name="IncompatibleFeatures", + save_before_dump=True, + ) + def test_load_masters_layerName_without_required_font(): ds = DesignSpaceDocument() s = SourceDescriptor()