示例#1
0
 def test_complex_union(self) -> None:
     complex_union = py_deprecated_types.Union(
         simpleField=py_deprecated_types.Simple(
             intField=42,
             strField="simple",
             intList=[1, 2, 3],
             strSet={"hello", "world"},
             strToIntMap={
                 "one": 1,
                 "two": 2
             },
             color=py_deprecated_types.Color.NONE,
         ))._to_python()
     self.assertEqual(complex_union.type, python_types.Union.Type.simple_)
     self.assertEqual(complex_union.simple_.intField, 42)
示例#2
0
 def test_complex_union(self) -> None:
     complex_union = to_py3_struct(
         types.Union,
         ttypes.Union(simpleField=ttypes.Simple(
             intField=42,
             strField="simple",
             intList=[1, 2, 3],
             strSet={"hello", "world"},
             strToIntMap={
                 "one": 1,
                 "two": 2
             },
             color=ttypes.Color.NONE,
         )),
     )
     self.assertEqual(complex_union.type, types.Union.Type.simpleField)
     self.assertEqual(complex_union.simpleField.intField, 42)
示例#3
0
 def test_union_with_containers(self) -> None:
     union_with_list = py_deprecated_types.Union(
         intList=[1, 2, 3])._to_python()
     self.assertEqual(union_with_list.type, python_types.Union.Type.intList)
     self.assertEqual(union_with_list.value, [1, 2, 3])
示例#4
0
 def test_union_with_py3_name_annotation(self) -> None:
     simple_union = py_deprecated_types.Union(name="myname")._to_python()
     self.assertEqual(simple_union.type, python_types.Union.Type.name_)
     self.assertEqual(simple_union.value, "myname")
示例#5
0
 def test_simple_union(self) -> None:
     simple_union = py_deprecated_types.Union(intField=42)._to_python()
     self.assertEqual(simple_union.type, python_types.Union.Type.intField)
     self.assertEqual(simple_union.value, 42)
示例#6
0
 def test_union_with_containers(self) -> None:
     union_with_list = to_py3_struct(types.Union,
                                     ttypes.Union(intList=[1, 2, 3]))
     self.assertEqual(union_with_list.type, types.Union.Type.intList)
     self.assertEqual(union_with_list.value, [1, 2, 3])
示例#7
0
 def test_union_with_py3_name_annotation(self) -> None:
     # pyre-fixme[28]: Unexpected keyword argument `name`.
     simple_union = to_py3_struct(types.Union, ttypes.Union(name="myname"))
     self.assertEqual(simple_union.type, types.Union.Type.name_)
     self.assertEqual(simple_union.value, "myname")
示例#8
0
 def test_simple_union(self) -> None:
     simple_union = to_py3_struct(types.Union, ttypes.Union(intField=42))
     self.assertEqual(simple_union.type, types.Union.Type.intField)
     self.assertEqual(simple_union.value, 42)
示例#9
0
 def test_union_with_py3_name_annotation(self) -> None:
     simple_union = to_py3_struct(types.Union, ttypes.Union(name="myname"))
     self.assertEqual(simple_union.type, types.Union.Type.name_)
     self.assertEqual(simple_union.value, "myname")