コード例 #1
0
 def test_set(self) -> None:
     bar, baz = ComplexRef(name="bar"), ComplexRef(name="baz")
     x = ComplexRef(name="foo",
                    set_basetype_ref={1, 2, 3},
                    set_recursive_ref={bar, baz})
     self.assertEqual(x.set_basetype_ref, {1, 2, 3})
     self.assertEqual(x.set_recursive_ref, {bar, baz})
コード例 #2
0
 def test_list(self) -> None:
     bar, baz = ComplexRef(name="bar"), ComplexRef(name="baz")
     x = ComplexRef(name="foo",
                    list_basetype_ref=[1, 2, 3],
                    list_recursive_ref=[bar, baz])
     self.assertEqual(x.list_basetype_ref, [1, 2, 3])
     self.assertEqual(x.list_recursive_ref, [bar, baz])
コード例 #3
0
 def test_map(self) -> None:
     bar, baz = ComplexRef(name="bar"), ComplexRef(name="baz")
     x = ComplexRef(
         name="foo",
         map_basetype_ref={
             1: 1,
             2: 2,
             3: 3
         },
         map_recursive_ref={
             1: bar,
             2: baz
         },
     )
     self.assertEqual(x.map_basetype_ref, {1: 1, 2: 2, 3: 3})
     self.assertEqual(x.map_recursive_ref, {1: bar, 2: baz})
コード例 #4
0
 def test_create_default(self) -> None:
     x = ComplexRef()
     self.assertEqual(x.name, "")
     self.assertIsNone(x.list_basetype_ref)
     self.assertIsNone(x.list_recursive_ref)
     self.assertIsNone(x.set_basetype_ref)
     self.assertIsNone(x.set_recursive_ref)
     self.assertIsNone(x.map_basetype_ref)
     self.assertIsNone(x.map_recursive_ref)
コード例 #5
0
 def test_recursive(self) -> None:
     bar = ComplexRef(name="bar")
     baz = ComplexRef(recursive=bar)
     self.assertEqual(baz.recursive, bar)
コード例 #6
0
 def test_const_shared_ref(self) -> None:
     bar, baz = ComplexRef(name="bar"), ComplexRef(name="baz")
     x = ComplexRef(name="foo", set_const_shared_ref={bar, baz})
     self.assertEqual(x.set_const_shared_ref, {bar, baz})
コード例 #7
0
 def test_shared_ref(self) -> None:
     bar, baz = ComplexRef(name="bar"), ComplexRef(name="baz")
     x = ComplexRef(name="foo", list_shared_ref=[bar, baz])
     self.assertEqual(x.list_shared_ref, [bar, baz])
コード例 #8
0
 def test_single(self) -> None:
     x = ComplexRef(name="foo", ref=ComplexRef(name="bar"))
     self.assertIsNotNone(x.ref)
     assert x.ref  # for type checking
     self.assertEqual(x.ref.name, "bar")