Fix yaql / json_pp deprecation warning
By default deprecationwarnings only trigger once per invocation, so this test dependent strongly on execution order of all the tests to pass. by enforcing warnings to be enabled while recording for deprecationwarnings we can make this more reliable. Change-Id: I657786b8c73488203f8b056adc65df77e084ec85
This commit is contained in:
parent
1764e25f56
commit
2cd1e6ad35
|
@ -16,6 +16,7 @@
|
|||
|
||||
import datetime
|
||||
import json
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
import mock
|
||||
|
@ -139,6 +140,10 @@ class YaqlEvaluatorTest(base.BaseTest):
|
|||
|
||||
def test_function_json_pp_deprecation(self):
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
# ensure warnings aren't suppressed from other tests
|
||||
for name, mod in list(sys.modules.items()):
|
||||
getattr(mod, '__warningregistry__', dict()).clear()
|
||||
warnings.simplefilter('always')
|
||||
result = self._evaluator.evaluate('json_pp($)', '3')
|
||||
self.assertEqual('"3"', result)
|
||||
self.assertEqual(len(w), 1)
|
||||
|
|
Loading…
Reference in New Issue