summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli/base_vyostest_shim.py
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2022-04-26 08:22:03 -0500
committerJohn Estabrook <jestabro@vyos.io>2022-04-26 13:49:22 -0500
commit846098fd8a2e2b7025f6976e26e8b21f4ebe2466 (patch)
tree979cf8c8318f42810f9ecca94446ae01d3d3f884 /smoketest/scripts/cli/base_vyostest_shim.py
parentec3e1e43d24b823c5804ba80cdcbbfec25f7ea3a (diff)
downloadvyos-1x-846098fd8a2e2b7025f6976e26e8b21f4ebe2466.tar.gz
vyos-1x-846098fd8a2e2b7025f6976e26e8b21f4ebe2466.zip
smoketest: http: add decorator to suppress warnings locally
Diffstat (limited to 'smoketest/scripts/cli/base_vyostest_shim.py')
-rw-r--r--smoketest/scripts/cli/base_vyostest_shim.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/base_vyostest_shim.py b/smoketest/scripts/cli/base_vyostest_shim.py
index 1652aa0d6..7cfb53045 100644
--- a/smoketest/scripts/cli/base_vyostest_shim.py
+++ b/smoketest/scripts/cli/base_vyostest_shim.py
@@ -16,6 +16,7 @@ import os
import unittest
from time import sleep
+from typing import Type
from vyos.configsession import ConfigSession
from vyos.configsession import ConfigSessionError
@@ -85,3 +86,17 @@ class VyOSUnitTestSHIM:
print(f'\n\ncommand "{command}" returned:\n')
pprint.pprint(out)
return out
+
+# standard construction; typing suggestion: https://stackoverflow.com/a/70292317
+def ignore_warning(warning: Type[Warning]):
+ import warnings
+ from functools import wraps
+
+ def inner(f):
+ @wraps(f)
+ def wrapped(*args, **kwargs):
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", category=warning)
+ return f(*args, **kwargs)
+ return wrapped
+ return inner