Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maximlt authored and jbednar committed Oct 8, 2021
1 parent b5567b4 commit 5e725e6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
8 changes: 4 additions & 4 deletions tests/API0/testlistselector.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_set_object_not_None(self):
p.g = [7]
try:
p.g = None
except TypeError:
except ValueError:
pass
else:
raise AssertionError("Object set outside range.")
Expand Down Expand Up @@ -110,12 +110,12 @@ class Q(param.Parameterized):
### new tests (not copied from testobjectselector)

def test_bad_default(self):
with self.assertRaises(TypeError):
with self.assertRaises(ValueError):
class Q(param.Parameterized):
r = param.ListSelector(default=6,check_on_set=True)

def test_implied_check_on_set(self):
with self.assertRaises(TypeError):
with self.assertRaises(ValueError):
class Q(param.Parameterized):
r = param.ListSelector(default=7,objects=[7,8])

Expand All @@ -135,7 +135,7 @@ def test_set_checked_to_be_iterable(self):
class Q(param.Parameterized):
r = param.ListSelector(default=6,check_on_set=False)

with self.assertRaises(TypeError):
with self.assertRaises(ValueError):
Q.r = 6
##########################

Expand Down
21 changes: 17 additions & 4 deletions tests/API1/testlistselector.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_set_object_not_None(self):
p.g = [7]
try:
p.g = None
except TypeError:
except ValueError:
pass
else:
raise AssertionError("Object set outside range.")
Expand Down Expand Up @@ -109,12 +109,12 @@ class Q(param.Parameterized):
### new tests (not copied from testobjectselector)

def test_bad_default(self):
with self.assertRaises(TypeError):
with self.assertRaises(ValueError):
class Q(param.Parameterized):
r = param.ListSelector(default=6,check_on_set=True)

def test_implied_check_on_set(self):
with self.assertRaises(TypeError):
with self.assertRaises(ValueError):
class Q(param.Parameterized):
r = param.ListSelector(default=7,objects=[7,8])

Expand All @@ -134,7 +134,7 @@ def test_set_checked_to_be_iterable(self):
class Q(param.Parameterized):
r = param.ListSelector(default=6,check_on_set=False)

with self.assertRaises(TypeError):
with self.assertRaises(ValueError):
Q.r = 6
##########################

Expand All @@ -154,3 +154,16 @@ class Q(param.Parameterized):

with self.assertRaises(TypeError):
Q.param.params('r').compute_default()

def test_initialization_bad_iterable(self):
with self.assertRaises(ValueError):
class Q(param.Parameterized):
j = param.ListSelector('ab', ['a', 'b', 'c', 'd'])

def test_set_bad_iterable(self):
class Q(param.Parameterized):
r = param.ListSelector(objects=['a', 'b', 'c', 'd'])

q = Q()
with self.assertRaises(ValueError):
q.r = 'ab'

0 comments on commit 5e725e6

Please sign in to comment.