compat: suppress deprecation warnings that are internal or during test.

This commit is contained in:
whitequark 2019-01-26 15:43:00 +00:00
parent 7890c0adc8
commit 4bf80a6e33
3 changed files with 32 additions and 11 deletions

View file

@ -1,6 +1,6 @@
import warnings
from collections import OrderedDict
from ...tools import _ignore_deprecated
from ...hdl.xfrm import ValueTransformer, StatementTransformer
from ...hdl.ast import *
from ..fhdl.module import CompatModule, CompatFinalizeError
@ -153,6 +153,7 @@ class FSM(CompatModule):
self.sync += signal.eq(self.before_leaving(state))
return signal
@_ignore_deprecated
def do_finalize(self):
nstates = len(self.actions)
self.encoding = dict((s, n) for n, s in enumerate(self.actions.keys()))
@ -178,7 +179,6 @@ class FSM(CompatModule):
def _finalize_sync(self, ls):
cases = dict((self.encoding[k], ls.on_statement(v)) for k, v in self.actions.items() if v)
with warnings.catch_warnings():
self.comb += [
self.next_state.eq(self.state),
Case(self.state, cases).makedefault(self.encoding[self.reset_state])

View file

@ -1,9 +1,11 @@
from ...tools import _ignore_deprecated
from ...compat import *
from ...compat.fhdl import verilog
class SimCase:
def setUp(self, *args, **kwargs):
with _ignore_deprecated():
self.tb = self.TestBench(*args, **kwargs)
def test_to_verilog(self):

View file

@ -1,6 +1,8 @@
from collections.abc import Iterable
import contextlib
import functools
import warnings
from collections.abc import Iterable
from contextlib import contextmanager
__all__ = ["flatten", "union", "log2_int", "bits_for", "deprecated"]
@ -54,6 +56,23 @@ def deprecated(message, stacklevel=2):
return decorator
def _ignore_deprecated(f=None):
if f is None:
@contextlib.contextmanager
def context_like():
with warnings.catch_warnings():
warnings.filterwarnings(action="ignore", category=DeprecationWarning)
yield
return context_like()
else:
@functools.wraps(f)
def decorator_like(*args, **kwargs):
with warnings.catch_warnings():
warnings.filterwarnings(action="ignore", category=DeprecationWarning)
f(*args, **kwargs)
return decorator_like
def extend(cls):
def decorator(f):
if isinstance(f, property):