docstr: For a config that contains a dict inside it, verify that config
  can be correctly created from a json/dict, and config can be correctly
  serialized and de-serialized
docstr_tok: ["For","a","config","that","contains","a","dict","inside","it",",","verify","that","config","can","be","correctly","created","from","a","json\/dict",",","and","config","can","be","correctly","serialized","and","de-serialized"]
code: def test_config_to_json_for_union_with_baa(self):
      """For a config that contains a dict inside it, verify that config
      can be correctly created from a json/dict, and config can be correctly
      serialized and de-serialized
      """
  
      class Boo(ConfigBase):
          aye: str
  
      class Baa(ConfigBase):
          oye: int
  
      class TestConfigContainer(ConfigBase):
          class TestConfig(ConfigBase):
              a_union: Union[Boo, Baa]
  
          test_config: TestConfig
  
      an_int = 1
      a_baa = {"baa": {"oye": an_int}}
      a_config_containing_union = {"test_config": {"a_union": a_baa}}
      pytext_config = serialize.config_from_json(
          TestConfigContainer, a_config_containing_union
      )
      # verify that a_dict was read correctly
      self.assertEqual(pytext_config.test_config.a_union.oye, an_int)
      # serialize config to json, and deserialize back to config
      # verify that nothing changed
      jsonified_config = serialize.config_to_json(
          TestConfigContainer, pytext_config
      )
      pytext_config_deserialized = serialize.config_from_json(
          TestConfigContainer, jsonified_config
      )
      self.assertEqual(pytext_config, pytext_config_deserialized)
  
file_path: pytext/pytext/config/test/serialize_test.py
imports: import unittest
  from typing import Any, Dict, List, Union
  from pytext.config import ConfigBase, pytext_config_from_json, serialize
label_desc: Use image node_id 7 for calling the SerializeTest obj's underlying member method code with example usage: obj.test_config_to_json_for_union_with_baa() without return types