コード例 #1
0
    def test_check_paths(self):
        """Test StyleChecker.check_paths()."""
        checker = StyleChecker(configuration=None)
        mock_check_file = self._mock_check_file
        mock_os = self.MockOs()

        # Confirm that checked files is empty at the outset.
        self.assertEquals(self._checked_files, [])
        checker.check_paths(["path1", "directory"],
                            mock_check_file=mock_check_file,
                            mock_os=mock_os)
        self.assertEquals(self._checked_files,
                          ["path1",
                           os.path.join("dir_path1", "file1"),
                           os.path.join("dir_path1", "file2"),
                           os.path.join("dir_path2", "file3")])
コード例 #2
0
    def call_check_file(self, file_path):
        """Call the check_file() method of a test StyleChecker instance."""
        # Confirm that the attributes are reset.
        self.assert_attributes(None, None, None, "")

        # Create a test StyleChecker instance.
        #
        # The verbosity attribute is the only ProcessorOptions
        # attribute that needs to be checked in this test.
        # This is because it is the only option is directly
        # passed to the constructor of a style processor.
        options = ProcessorOptions(verbosity=3)

        style_checker = StyleChecker(options, self.mock_stderr_write)

        style_checker.check_file(file_path, self.mock_handle_style_error, self.mock_process_file)
コード例 #3
0
    def call_check_file(self, file_path):
        """Call the check_file() method of a test StyleChecker instance."""
        # Confirm that the attributes are reset.
        self.assert_attributes(None, None, None, "")

        # Create a test StyleChecker instance.
        #
        # The verbosity attribute is the only ProcessorOptions
        # attribute that needs to be checked in this test.
        # This is because it is the only option is directly
        # passed to the constructor of a style processor.
        options = ProcessorOptions(verbosity=3)

        style_checker = StyleChecker(options, self.mock_stderr_write)

        style_checker.check_file(file_path, self.mock_handle_style_error,
                                 self.mock_process_file)
コード例 #4
0
    def call_check_file(self, file_path):
        """Call the check_file() method of a test StyleChecker instance."""
        # Confirm that the attributes are reset.
        self.assert_attributes(None, None, None, "")

        configuration = self._style_checker_configuration()

        style_checker = StyleChecker(configuration)

        style_checker.check_file(file_path=file_path,
            mock_handle_style_error=self.mock_handle_style_error,
            mock_os_path_exists=self.mock_os_path_exists,
            mock_process_file=self.mock_process_file)

        file_count = 1 if self.mock_os_path_exists(file_path) else 0

        self.assertEquals(file_count, style_checker.file_count)
コード例 #5
0
 def _style_checker(self, options):
     return StyleChecker(options, self._mock_stderr_write)