Beispiel #1
0
 def test_get(self) -> None:
     x = StrStrMap({"test": "value"})
     self.assertEqual(x.get("test"), "value")
     # pyre-fixme[6]: Expected `str` for 1st param but got `int`.
     self.assertIs(x.get(5), None)
     # pyre-fixme[6]: Expected `str` for 1st param but got `Map__string_string`.
     self.assertIs(x.get(x), None)
Beispiel #2
0
 def test_getitem(self) -> None:
     x = StrStrMap({"test": "value"})
     self.assertEqual(x["test"], "value")
     with self.assertRaises(KeyError):
         x[5]  # type: ignore
     with self.assertRaises(KeyError):
         x[x]  # type: ignore
Beispiel #3
0
 def test_getitem(self) -> None:
     x = StrStrMap({"test": "value"})
     self.assertEqual(x["test"], "value")
     with self.assertRaises(KeyError):
         # pyre-fixme[6]: Expected `str` for 1st param but got `int`.
         x[5]
     with self.assertRaises(KeyError):
         # pyre-fixme[6]: Expected `str` for 1st param but got `Map__string_string`.
         x[x]
Beispiel #4
0
 def test_items_values(self) -> None:
     x = {"test": "value"}
     tx = StrStrMap(x)
     self.assertEqual(list(x.values()), list(tx.values()))
     self.assertEqual(list(x.keys()), list(tx.keys()))
     self.assertEqual(list(x.items()), list(tx.items()))
Beispiel #5
0
 def test_contains(self) -> None:
     x = StrStrMap({"test": "value"})
     self.assertIn("test", x)
     self.assertNotIn(5, x)
     self.assertNotIn(x, x)
Beispiel #6
0
 def test_get(self) -> None:
     x = StrStrMap({"test": "value"})
     self.assertEqual(x.get("test"), "value")
     self.assertIs(x.get(5), None)  # type: ignore
     self.assertIs(x.get(x), None)  # type: ignore
Beispiel #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)
Beispiel #8
0
 def test_pickle_mapping(self) -> None:
     control = StrStrMap({"test": "test", "foo": "bar"})
     self.pickle_round_robin(control)
Beispiel #9
0
 def test_items_values(self) -> None:
     x = {"test": "value"}
     tx = StrStrMap(x)
     self.assertEqual(list(x.values()), list(tx.values()))
     self.assertEqual(list(x.keys()), list(tx.keys()))
     self.assertEqual(list(x.items()), list(tx.items()))
Beispiel #10
0
 def test_get(self) -> None:
     x = StrStrMap({"test": "value"})
     self.assertEqual(x.get("test"), "value")
     self.assertIs(x.get(5), None)  # type: ignore
     self.assertIs(x.get(x), None)  # type: ignore