Skip to content

Commit

Permalink
Add tests for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
GDYendell committed Jul 12, 2016
1 parent dc2cd59 commit a4590a8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion malcolm/core/numberarraymeta.py
Expand Up @@ -38,7 +38,7 @@ def validate(self, value):
% type(value))
if value.dtype != numpy.dtype(self.dtype()):
raise TypeError("Expected %s, got %s" %
(self.numpy_type(), value.dtype))
(numpy.dtype(self.dtype()), value.dtype))
return value

def to_dict(self):
Expand Down
14 changes: 14 additions & 0 deletions tests/test_core/test_numberarraymeta.py
Expand Up @@ -54,6 +54,20 @@ def test_numpy_array(self):
for i, value in enumerate(response):
self.assertEqual(values[i], value)

def test_numpy_array_wrong_type_raises(self):
nm = NumberArrayMeta("nm", "desc", np.float64)
values = "[1.2, 3.4, 5.6]"

with self.assertRaises(TypeError):
nm.validate(values)

def test_numpy_array_wrong_number_type_raises(self):
nm = NumberArrayMeta("nm", "desc", np.int32)
values = np.array([1.2, 3.4, 5.6])

with self.assertRaises(TypeError):
nm.validate(values)

def test_float_against_float64(self):
nm = NumberArrayMeta("nm", "desc", np.float64)
values = [1.2, 3.4, 5.6]
Expand Down

0 comments on commit a4590a8

Please sign in to comment.