Beispiel #1
0
 def test_mixed_construction(self) -> None:
     x = SetI32Lists({(0, 1, 2), (3, 4, 5)})
     z = SetSetI32Lists({x})
     pz = set(z)
     pz.add(x)
     nx: AbstractSet[Sequence[int]] = {(9, 10, 11)}
     pz.add(SetI32Lists(nx))
     cz = SetSetI32Lists(pz)
     self.assertIn(nx, cz)
     pz.add(5)  # type: ignore
     with self.assertRaises(TypeError):
         SetSetI32Lists(pz)
Beispiel #2
0
 def test_mixed_construction(self):
     x = SetI32Lists({(0, 1, 2), (3, 4, 5)})
     z = SetSetI32Lists({x})
     pz = set(z)
     pz.add(x)
     nx = {(9, 10, 11)}
     pz.add(SetI32Lists(nx))
     cz = SetSetI32Lists(pz)
     self.assertIn(nx, cz)
     pz.add(5)
     with self.assertRaises(TypeError):
         SetSetI32Lists(pz)
Beispiel #3
0
 def test_mixed_construction(self) -> None:
     x = SetI32Lists({(0, 1, 2), (3, 4, 5)})
     z = SetSetI32Lists({x})
     pz = set(z)
     pz.add(x)
     nx: AbstractSet[Sequence[int]] = {(9, 10, 11)}
     pz.add(SetI32Lists(nx))
     cz = SetSetI32Lists(pz)
     self.assertIn(nx, cz)
     # pyre-fixme[6]: Expected `AbstractSet[Sequence[int]]` for 1st param but got
     #  `int`.
     pz.add(5)
     with self.assertRaises(TypeError):
         SetSetI32Lists(pz)
Beispiel #4
0
 def test_cached_set(self) -> None:
     uncached = SetI32Lists({(0, 1, 2)})
     # default no cache, so every access creates a new instance
     self.assertIsNot(list(uncached)[0], list(uncached)[0])
     # with cache they should be same
     self.assertIs(
         list(to_frozenset(uncached))[0],
         list(to_frozenset(uncached))[0])
Beispiel #5
0
 def test_None(self) -> None:
     with self.assertRaises(TypeError):
         # pyre-fixme[6]: Expected `Optional[AbstractSet[Sequence[int]]]` for 1st
         #  param but got `Set[None]`.
         SetI32Lists({None})
     with self.assertRaises(TypeError):
         # pyre-fixme[6]: Expected
         #  `Optional[AbstractSet[AbstractSet[Sequence[int]]]]` for 1st param but
         #  got `Set[typing.Set[None]]`.
         SetSetI32Lists({{None}})
Beispiel #6
0
 def test_None(self) -> None:
     with self.assertRaises(TypeError):
         SetI32Lists({None})  # type: ignore
     with self.assertRaises(TypeError):
         SetSetI32Lists({{None}})  # type: ignore
Beispiel #7
0
 def test_hashability(self) -> None:
     hash(SetI32Lists())
     z = SetSetI32Lists({SetI32Lists({(1, 2, 3)})})
     hash(z)
     for sub_set in z:
         hash(sub_set)
Beispiel #8
0
 def test_empty(self) -> None:
     SetI32Lists(set())
     SetI32Lists({()})
     SetSetI32Lists(set())
     SetSetI32Lists({SetI32Lists()})
     SetSetI32Lists({SetI32Lists({()})})
Beispiel #9
0
 def test_is_container(self) -> None:
     self.assertIsInstance(SetI32Lists(), Container)
     self.assertIsInstance(SetSetI32Lists(), Container)
     self.assertIsInstance(SetI32(), Container)
Beispiel #10
0
 def test_None(self):
     with self.assertRaises(TypeError):
         SetI32Lists({None})
     with self.assertRaises(TypeError):
         SetSetI32Lists({{None}})