Пример #1
0
 def test_dependency(self):
     input_options = datatypes.SimpleNamespace(output="test.pyi",
                                               check=None)
     config.Postprocessor({"output", "check"}, input_options,
                          self.output_options).process()
     self.assertEqual(self.output_options.output, "test.pyi")
     self.assertIs(self.output_options.check, False)
Пример #2
0
 def test_typeshed_default(self):
   input_options = datatypes.SimpleNamespace(
       typeshed=None, precompiled_builtins=None)
   config.Postprocessor({"typeshed", "precompiled_builtins"}, input_options,
                        self.output_options).process()
   # We only care that `None` was replaced.
   self.assertIsNotNone(self.output_options.typeshed)
Пример #3
0
 def test_populate_from(self):
   conf = config.Config()
   self._validate_empty_contents(conf)
   conf.populate_from(
       datatypes.SimpleNamespace(**{k: 42 for k in config.ITEMS}))
   for k in config.ITEMS:
     self.assertEqual(getattr(conf, k), 42)
Пример #4
0
 def test_disable_and_enable_only(self):
   input_options = datatypes.SimpleNamespace(
       disable="import-error,attribute-error",
       enable_only="bad-slots,bad-unpacking")
   with self.assertRaises(config.PostprocessingError) as _:
     config.Postprocessor({"disable", "enable_only"}, input_options,
                          self.output_options).process()
Пример #5
0
 def test_io_pair_output(self):
   input_options = datatypes.SimpleNamespace(input=["in.py:out.pyi"])
   config.Postprocessor(
       {"output"}, input_options, self.output_options).process()
   with self.assertRaises(AttributeError):
     _ = self.output_options.input
   self.assertEqual(self.output_options.output, "out.pyi")
Пример #6
0
 def test_inplace(self):
   input_options = datatypes.SimpleNamespace(
       disable="import-error,attribute-error", python_version="3.4")
   config.Postprocessor(
       {"disable", "python_version"}, input_options).process()
   self.assertSequenceEqual(
       input_options.disable, ["import-error", "attribute-error"])
   self.assertTupleEqual(input_options.python_version, (3, 4))
Пример #7
0
 def test_subset(self):
   input_options = datatypes.SimpleNamespace(
       pythonpath=".", python_version="3.4")
   config.Postprocessor(
       {"python_version"}, input_options, self.output_options).process()
   with self.assertRaises(AttributeError):
     _ = self.output_options.pythonpath  # not processed
   self.assertTupleEqual(self.output_options.python_version, (3, 4))
Пример #8
0
 def test_enable_only(self):
     input_options = datatypes.SimpleNamespace(
         disable=None, enable_only="import-error,attribute-error")
     config.Postprocessor({"disable", "enable_only"}, input_options,
                          self.output_options).process()
     self.assertIn("python-compiler-error", self.output_options.disable)
     self.assertNotIn("import-error", self.output_options.disable)
     self.assertNotIn("attribute-error", self.output_options.disable)
Пример #9
0
 def test_populate_from_none(self):
   conf = config.Config()
   self._validate_empty_contents(conf)
   # None is a valid value.
   conf.populate_from(
       datatypes.SimpleNamespace(**{k: None for k in config.ITEMS}))
   for k in config.ITEMS:
     self.assertIsNone(getattr(conf, k))
Пример #10
0
 def test_io_pair_input(self):
   # The duplicate output is ignored, since we're only processing the input.
   input_options = datatypes.SimpleNamespace(
       input=["in.py:out.pyi"], output="out2.pyi")
   config.Postprocessor(
       {"input"}, input_options, self.output_options).process()
   self.assertEqual(self.output_options.input, "in.py")
   with self.assertRaises(AttributeError):
     _ = self.output_options.output
Пример #11
0
 def test_typeshed(self):
   input_options = datatypes.SimpleNamespace(
       typeshed=False, precompiled_builtins=None)
   config.Postprocessor({"typeshed", "precompiled_builtins"}, input_options,
                        self.output_options).process()
   self.assertIs(self.output_options.typeshed, False)
Пример #12
0
 def test_error(self):
   input_options = datatypes.SimpleNamespace(check=True, output="test.pyi")
   with self.assertRaises(config.PostprocessingError):
     config.Postprocessor(
         {"check", "output"}, input_options, self.output_options).process()
Пример #13
0
 def setUp(self):
   super(PostprocessorTest, self).setUp()
   self.output_options = datatypes.SimpleNamespace()
Пример #14
0
 def test_io_pair(self):
   input_options = datatypes.SimpleNamespace(input=["in.py:out.pyi"])
   config.Postprocessor(
       {"input", "output"}, input_options, self.output_options).process()
   self.assertEqual(self.output_options.input, "in.py")
   self.assertEqual(self.output_options.output, "out.pyi")
Пример #15
0
 def test_postprocess_from_strings(self):
     args = datatypes.SimpleNamespace(report_errors='False',
                                      protocols='True')
     self.parser.postprocess(args, from_strings=True)
     self.assertFalse(args.report_errors)
     self.assertTrue(args.protocols)
Пример #16
0
 def test_postprocess(self):
     args = datatypes.SimpleNamespace(disable='import-error')
     self.parser.postprocess(args)
     self.assertSequenceEqual(args.disable, ['import-error'])
Пример #17
0
 def test_python_version_default(self):
   input_options = datatypes.SimpleNamespace(python_version=None)
   config.Postprocessor({"python_version"}, input_options,
                        self.output_options).process()
   self.assertEqual(self.output_options.python_version,
                    (sys.version_info.major, sys.version_info.minor))
Пример #18
0
 def test_io_pair_multiple_output(self):
   input_options = datatypes.SimpleNamespace(
       input=["in.py:out.pyi"], output="out2.pyi")
   with self.assertRaises(config.PostprocessingError):
     config.Postprocessor(
         {"output"}, input_options, self.output_options).process()
Пример #19
0
 def test_input(self):
   input_options = datatypes.SimpleNamespace(input=["test.py"])
   config.Postprocessor(
       {"input"}, input_options, self.output_options).process()
   self.assertEqual(self.output_options.input, "test.py")
Пример #20
0
 def setUp(self):
     self.output_options = datatypes.SimpleNamespace()