Skip to content

Commit

Permalink
Add tests of deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
cdonovick committed Jun 27, 2019
1 parent e9ca6da commit e2c213b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion hwtypes/bit_vector_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def __call__(cls, value=_MISSING, *args, **kwargs):
else:
return super().__call__(value, *args, **kwargs)
else:
warnings.warn('DEPRECATION WARNING: Use of implicitly sized BitVectors is deprecated')
warnings.warn('DEPRECATION WARNING: Use of implicitly sized '
'BitVectors is deprecated', DeprecationWarning)

if value is _MISSING:
raise TypeError('Cannot construct {} without a value'.format(cls, value))
Expand Down
11 changes: 11 additions & 0 deletions tests/test_bv.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,14 @@ def test_setitem():
assert repr(bv) == 'BitVector[3](6)'
bv[2] = 0
assert repr(bv) == 'BitVector[3](2)'

@pytest.mark.parametrize("val", [
BitVector.random(8),
BitVector.random(8).as_sint(),
BitVector.random(8).as_uint(),
[0,1,1,0],
])
def test_deprecated(val):
with pytest.warns(DeprecationWarning):
BitVector(val)

0 comments on commit e2c213b

Please sign in to comment.