Skip to content

Commit 78711f4

Browse files
committed
silence test deprecation warning
1 parent 8760cca commit 78711f4

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎test/test_macrospec_pyltxenc2_compat.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
### BEGIN_PYLATEXENC2_LEGACY_SUPPORT_CODE
1010

11+
import warnings
12+
1113
from pylatexenc import latexwalker
1214

1315
from pylatexenc.latexnodes import ParsingStateDeltaEnterMathMode
@@ -64,6 +66,18 @@ def _environment_body_parsing_state(spec, latex):
6466

6567
class TestCallableSpecLegacyArgsParser(unittest.TestCase):
6668

69+
def setUp(self):
70+
# `args_parser=` is deprecated on purpose here; these tests check that
71+
# it keeps working, so the deprecation warnings it emits are expected
72+
# and would only clutter the test output. (The filter has to be set up
73+
# in setUp(), and not in the constructor, because pytest installs its
74+
# own warning filters for the duration of each individual test.)
75+
catch_warnings = warnings.catch_warnings()
76+
catch_warnings.__enter__()
77+
self.addCleanup(catch_warnings.__exit__, None, None, None)
78+
warnings.simplefilter('ignore', DeprecationWarning)
79+
80+
6781
def test_args_parser_as_string_provides_the_arguments(self):
6882
# MacroSpec('foo', args_parser='{[') must accept the very same arguments
6983
# as MacroSpec('foo', '{[')

0 commit comments

Comments
 (0)