class_docstr: Test functionality related to --init-opt.
class_docstr_tok: ["Test","functionality","related","to","--","init-opt","."]
docstr: Test --allow-missing-init-opts.
docstr_tok: ["Test","--","allow-missing-init-opts","."]
code: def test_allow_missing_init_opts(self):
      """
      Test --allow-missing-init-opts.
      """
  
      with testing_utils.tempdir() as temp_dir:
          init_opt_path = os.path.join(temp_dir, "init_opt.opt")
  
          # Save a test opt file with an argument that doesn't exist
          init_opt = Opt({"made_up_arg": "foo"})
          init_opt.save(init_opt_path)
  
          # Assert that the opt file normally can't be loaded in
          with self.assertRaises(RuntimeError):
              _ = ParlaiParser(True, True).parse_kwargs(
                  init_opt=init_opt_path
              )
  
          # Assert that the opt file *can* be loaded in if we set
          # --allow-missing-init-opts, and assert that the made-up arg does not exist
          # in the opt
          opt = ParlaiParser(True, True).parse_kwargs(
              init_opt=init_opt_path, allow_missing_init_opts=True
          )
          self.assertFalse(hasattr(opt, "made_up_arg"))
  
imports: import json
  import os
  import unittest
  import parlai.utils.testing
  from parlai.core.agents import create_agent_from_opt_file
  from parlai.core.opt import Opt
  from parlai.core.params import ParlaiParser
  from parlai.scripts.compare_opts import compare_opts
label_desc: Use image node_id 2 for calling the TestInitOpt obj's underlying member method code with example usage: obj.test_allow_missing_init_opts() without return types