def test_convert_to_list_iterable(self): for item in ([None], [1, 2, 3], (1, 2, 3), set([1, 2, 3]), ['foo']): self.assertEqual(list(item), attributes.convert_to_list(item))
def test_convert_to_list_non_iterable(self): for item in (True, False, 1, 1.2, object()): self.assertEqual([item], attributes.convert_to_list(item))
def test_convert_to_empty_list(self): for item in (None, [], (), {}): self.assertEqual([], attributes.convert_to_list(item))
def test_convert_to_list_string(self): for item in ('', 'foo'): self.assertEqual([item], attributes.convert_to_list(item))
def test_convert_to_list_string(self): for item in ("", "foo"): self.assertEqual(attributes.convert_to_list(item), [item])
def normalize_port_pair_groups(port_pair_groups): port_pair_groups = attr.convert_to_list(port_pair_groups) if not port_pair_groups: raise PortPairGroupNotSpecified() return port_pair_groups