Skip to content

Commit

Permalink
Merge pull request #80 from leonardt/fail-old
Browse files Browse the repository at this point in the history
Make sure old style constructors fail properly
  • Loading branch information
cdonovick authored Jul 25, 2019
2 parents 2bc4bd9 + 5ee0bd3 commit acb4834
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hwtypes/bit_vector_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __call__(cls, value=_MISSING, *args, **kwargs):
else:
raise TypeError('Cannot construct {} from {}'.format(cls, value))

return type(cls).__call__(cls[size], value)
return type(cls).__call__(cls[size], value, *args, **kwargs)


def __new__(mcs, name, bases, namespace, info=(None, None), **kwargs):
Expand Down
11 changes: 11 additions & 0 deletions tests/test_bv.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,14 @@ def test_deprecated(val):
with pytest.warns(DeprecationWarning):
BitVector(val)

@pytest.mark.parametrize("val", [
BitVector.random(4),
BitVector.random(4).as_sint(),
BitVector.random(4).as_uint(),
[0,1,1,0],
])
def test_old_style(val):
with pytest.warns(DeprecationWarning):
with pytest.raises(TypeError):
BitVector(val, 4)

0 comments on commit acb4834

Please sign in to comment.