예제 #1
0
 def _create_options(self,
                     output_format='emacs',
                     min_confidence=3,
                     filter_rules=[],
                     git_commit=None):
     return ProcessorOptions(filter_rules=filter_rules,
                             git_commit=git_commit,
                             min_confidence=min_confidence,
                             output_format=output_format)
예제 #2
0
    def test_init(self):
        """Test __init__ constructor."""
        # Check default parameters.
        options = ProcessorOptions()
        self.assertEqual(options.filter_rules, [])
        self.assertIsNone(options.git_commit)
        self.assertFalse(options.is_verbose)
        self.assertEqual(options.min_confidence, 1)
        self.assertEqual(options.output_format, "emacs")

        # Check argument validation.
        self.assertRaises(ValueError, ProcessorOptions, output_format="bad")
        ProcessorOptions(output_format="emacs")  # No ValueError: works
        ProcessorOptions(output_format="vs7")  # works
        self.assertRaises(ValueError, ProcessorOptions, min_confidence=0)
        self.assertRaises(ValueError, ProcessorOptions, min_confidence=6)
        ProcessorOptions(min_confidence=1)  # works
        ProcessorOptions(min_confidence=5)  # works

        # Check attributes.
        options = ProcessorOptions(filter_rules=["+"],
                                   git_commit="commit",
                                   is_verbose=True,
                                   min_confidence=3,
                                   output_format="vs7")
        self.assertEqual(options.filter_rules, ["+"])
        self.assertEqual(options.git_commit, "commit")
        self.assertTrue(options.is_verbose)
        self.assertEqual(options.min_confidence, 3)
        self.assertEqual(options.output_format, "vs7")
예제 #3
0
    def test_eq(self):
        """Test __eq__ equality function."""
        self.assertTrue(ProcessorOptions().__eq__(ProcessorOptions()))

        # Also verify that a difference in any argument causes equality to fail.

        # Explicitly create a ProcessorOptions instance with all default
        # values.  We do this to be sure we are assuming the right default
        # values in our self.assertFalse() calls below.
        options = ProcessorOptions(filter_rules=[],
                                   git_commit=None,
                                   is_verbose=False,
                                   min_confidence=1,
                                   output_format="emacs",
                                   git_index=False)
        # Verify that we created options correctly.
        self.assertTrue(options.__eq__(ProcessorOptions()))

        self.assertFalse(options.__eq__(ProcessorOptions(filter_rules=["+"])))
        self.assertFalse(options.__eq__(ProcessorOptions(git_commit="commit")))
        self.assertFalse(options.__eq__(ProcessorOptions(is_verbose=True)))
        self.assertFalse(options.__eq__(ProcessorOptions(min_confidence=2)))
        self.assertFalse(options.__eq__(ProcessorOptions(output_format="vs7")))
        self.assertFalse(options.__eq__(ProcessorOptions(git_index=True)))
예제 #4
0
 def test_ne(self):
     """Test __ne__ inequality function."""
     # By default, __ne__ always returns true on different objects.
     # Thus, just check the distinguishing case to verify that the
     # code defines __ne__.
     self.assertFalse(ProcessorOptions().__ne__(ProcessorOptions()))