Exemple #1
0
 def test_equality(self) -> None:
     x = StrIntMap({"foo": 5, "bar": 4})
     y = StrIntMap({"foo": 4, "bar": 5})
     self.assertNotEqual(x, y)
     y = StrIntMap({"foo": 5, "bar": 4})
     self.assertEqual(x, y)
     self.assertEqual(x, x)
     self.assertEqual(y, y)
Exemple #2
0
 def test_equality(self) -> None:
     x = StrIntMap({'foo': 5, 'bar': 4})
     y = StrIntMap({'foo': 4, 'bar': 5})
     self.assertNotEqual(x, y)
     y = StrIntMap({'foo': 5, 'bar': 4})
     self.assertEqual(x, y)
     self.assertEqual(x, x)
     self.assertEqual(y, y)
Exemple #3
0
 def test_None(self) -> None:
     with self.assertRaises(TypeError):
         StrIntMap({None: 5})  # type: ignore
     with self.assertRaises(TypeError):
         StrIntMap({"foo": None})  # type: ignore
     with self.assertRaises(TypeError):
         StrStrIntListMapMap({"bar": {"foo": [None, None]}})  # type: ignore
     with self.assertRaises(TypeError):
         StrStrIntListMapMap({"bar": {"foo": None}})  # type: ignore
Exemple #4
0
 def test_None(self):
     with self.assertRaises(TypeError):
         StrIntMap({None: 5})
     with self.assertRaises(TypeError):
         StrIntMap({'foo': None})
     with self.assertRaises(TypeError):
         StrStrIntListMapMap({'bar': {'foo': [None, None]}})
     with self.assertRaises(TypeError):
         StrStrIntListMapMap({'bar': {'foo': None}})
Exemple #5
0
 def test_None(self) -> None:
     with self.assertRaises(TypeError):
         # pyre-fixme[6]: Expected `Optional[typing.Mapping[str, int]]` for 1st
         #  param but got `Dict[None, int]`.
         StrIntMap({None: 5})
     with self.assertRaises(TypeError):
         # pyre-fixme[6]: Expected `Optional[typing.Mapping[str, int]]` for 1st
         #  param but got `Dict[str, None]`.
         StrIntMap({"foo": None})
     with self.assertRaises(TypeError):
         # pyre-fixme[6]: Expected `Optional[typing.Mapping[str,
         #  typing.Mapping[str, typing.Sequence[int]]]]` for 1st param but got
         #  `Dict[str, Dict[str, List[None]]]`.
         StrStrIntListMapMap({"bar": {"foo": [None, None]}})
     with self.assertRaises(TypeError):
         # pyre-fixme[6]: Expected `Optional[typing.Mapping[str,
         #  typing.Mapping[str, typing.Sequence[int]]]]` for 1st param but got
         #  `Dict[str, Dict[str, None]]`.
         StrStrIntListMapMap({"bar": {"foo": None}})
Exemple #6
0
 def test_empty(self) -> None:
     StrIntMap()
     StrIntMap({})
     StrStrIntListMapMap({})
     StrStrIntListMapMap({"foo": {}})
     StrStrIntListMapMap({"foo": {"bar": []}})
Exemple #7
0
 def test_is_container(self) -> None:
     self.assertIsInstance(LocationMap, Container)
     self.assertIsInstance(StrI32ListMap(), Container)
     self.assertIsInstance(StrIntMap(), Container)
     self.assertIsInstance(StrStrIntListMapMap(), Container)
     self.assertIsInstance(StrStrMap(), Container)
Exemple #8
0
 def test_empty(self) -> None:
     StrIntMap()
     StrIntMap({})
     StrStrIntListMapMap({})
     StrStrIntListMapMap({'foo': {}})
     StrStrIntListMapMap({'foo': {'bar': []}})