Exemplo n.º 1
0
 def test_string_hashing(self):
     h1 = Hasher()
     h1.update("Hello, world!")
     h2 = Hasher()
     h2.update("Goodbye!")
     h3 = Hasher()
     h3.update("Hello, world!")
     self.assertNotEqual(h1.digest(), h2.digest())
     self.assertEqual(h1.digest(), h3.digest())
Exemplo n.º 2
0
 def test_string_hashing(self):
     h1 = Hasher()
     h1.update("Hello, world!")
     h2 = Hasher()
     h2.update("Goodbye!")
     h3 = Hasher()
     h3.update("Hello, world!")
     self.assertNotEqual(h1.digest(), h2.digest())
     self.assertEqual(h1.digest(), h3.digest())
Exemplo n.º 3
0
    def report(self, morfs):
        """Generate an HTML report for `morfs`.

        `morfs` is a list of modules or filenames.

        """
        assert self.config.html_dir, "must give a directory for html reporting"

        # Read the status data.
        self.status.read(self.config.html_dir)

        # Check that this run used the same settings as the last run.
        m = Hasher()
        m.update(self.config)
        these_settings = m.digest()
        if self.status.settings_hash() != these_settings:
            self.status.reset()
            self.status.set_settings_hash(these_settings)

        # The user may have extra CSS they want copied.
        if self.config.extra_css:
            self.extra_css = os.path.basename(self.config.extra_css)

        # Process all the files.
        self.report_files(self.html_file, morfs, self.config.html_dir)

        if not self.files:
            raise CoverageException("No data to report.")

        # Write the index file.
        self.index_file()

        self.make_local_static_report_files()

        return self.totals.pc_covered
Exemplo n.º 4
0
    def report(self, morfs):
        """Generate an HTML report for `morfs`.

        `morfs` is a list of modules or filenames.

        """
        assert self.config.html_dir, "must give a directory for html reporting"

        # Read the status data.
        self.status.read(self.config.html_dir)

        # Check that this run used the same settings as the last run.
        m = Hasher()
        m.update(self.config)
        these_settings = m.digest()
        if self.status.settings_hash() != these_settings:
            self.status.reset()
            self.status.set_settings_hash(these_settings)

        # The user may have extra CSS they want copied.
        if self.config.extra_css:
            self.extra_css = os.path.basename(self.config.extra_css)

        # Process all the files.
        self.report_files(self.html_file, morfs, self.config.html_dir)

        if not self.files:
            raise CoverageException("No data to report.")

        # Write the index file.
        self.index_file()

        self.make_local_static_report_files()

        return self.totals.pc_covered
Exemplo n.º 5
0
    def report(self, morfs, config=None):
        """Generate an HTML report for `morfs`.

        `morfs` is a list of modules or filenames.  `config` is a
        CoverageConfig instance.

        """
        assert config.html_dir, "must provide a directory for html reporting"

        # Read the status data.
        self.status.read(config.html_dir)

        # Check that this run used the same settings as the last run.
        m = Hasher()
        m.update(config)
        these_settings = m.digest()
        if self.status.settings_hash() != these_settings:
            self.status.reset()
            self.status.set_settings_hash(these_settings)

        # Process all the files.
        self.report_files(self.html_file, morfs, config, config.html_dir)

        if not self.files:
            raise CoverageException("No data to report.")

        # Write the index file.
        self.index_file()

        # Create the once-per-directory files.
        for static in self.STATIC_FILES:
            shutil.copyfile(data_filename("htmlfiles/" + static),
                            os.path.join(self.directory, static))
Exemplo n.º 6
0
    def report(self, morfs, config=None):
        """Generate an HTML report for `morfs`.

        `morfs` is a list of modules or filenames.  `config` is a
        CoverageConfig instance.

        """
        assert config.html_dir, "must provide a directory for html reporting"

        # Read the status data.
        self.status.read(config.html_dir)

        # Check that this run used the same settings as the last run.
        m = Hasher()
        m.update(config)
        these_settings = m.digest()
        if self.status.settings_hash() != these_settings:
            self.status.reset()
            self.status.set_settings_hash(these_settings)

        # Process all the files.
        self.report_files(self.html_file, morfs, config, config.html_dir)

        if not self.files:
            raise CoverageException("No data to report.")

        # Write the index file.
        self.index_file()

        self.make_local_static_report_files()
Exemplo n.º 7
0
    def report(self, morfs, config=None):
        """Generate an HTML report for `morfs`.

        `morfs` is a list of modules or filenames.  `config` is a
        CoverageConfig instance.

        """
        assert config.html_dir, "must provide a directory for html reporting"

        # Read the status data.
        self.status.read(config.html_dir)

        # Check that this run used the same settings as the last run.
        m = Hasher()
        m.update(config)
        these_settings = m.digest()
        if self.status.settings_hash() != these_settings:
            self.status.reset()
            self.status.set_settings_hash(these_settings)

        # Process all the files.
        self.report_files(self.html_file, morfs, config, config.html_dir)

        if not self.files:
            raise CoverageException("No data to report.")

        # Write the index file.
        self.index_file()

        # Create the once-per-directory files.
        for static in self.STATIC_FILES:
            shutil.copyfile(
                data_filename("htmlfiles/" + static),
                os.path.join(self.directory, static)
                )
Exemplo n.º 8
0
 def report(self, morfs):
     self.status.read(self.config.html_dir)
     m = Hasher()
     m.update(self.config)
     these_settings = m.digest()
     if self.status.settings_hash() != these_settings:
         self.status.reset()
         self.status.set_settings_hash(these_settings)
     if self.config.extra_css:
         self.extra_css = os.path.basename(self.config.extra_css)
     self.report_files(self.html_file, morfs, self.config.html_dir)
     if not self.files:
         raise CoverageException('No data to report.')
     self.index_file()
     self.make_local_static_report_files()
     return self.totals.pc_covered
Exemplo n.º 9
0
 def report(self, morfs):
     self.status.read(self.config.html_dir)
     m = Hasher()
     m.update(self.config)
     these_settings = m.digest()
     if self.status.settings_hash() != these_settings:
         self.status.reset()
         self.status.set_settings_hash(these_settings)
     if self.config.extra_css:
         self.extra_css = os.path.basename(self.config.extra_css)
     self.report_files(self.html_file, morfs, self.config.html_dir)
     if not self.files:
         raise CoverageException('No data to report.')
     self.index_file()
     self.make_local_static_report_files()
     return self.totals.pc_covered
Exemplo n.º 10
0
 def test_dict_hashing(self):
     h1 = Hasher()
     h1.update({'a': 17, 'b': 23})
     h2 = Hasher()
     h2.update({'b': 23, 'a': 17})
     self.assertEqual(h1.digest(), h2.digest())
Exemplo n.º 11
0
 def file_hash(self, source, cu):
     """Compute a hash that changes if the file needs to be re-reported."""
     m = Hasher()
     m.update(source)
     self.coverage.data.add_to_hash(cu.filename, m)
     return m.digest()
Exemplo n.º 12
0
 def file_hash(self, source, cu):
     """Compute a hash that changes if the file needs to be re-reported."""
     m = Hasher()
     m.update(source)
     self.coverage.data.add_to_hash(cu.filename, m)
     return m.digest()
Exemplo n.º 13
0
 def test_dict_hashing(self):
     h1 = Hasher()
     h1.update({'a': 17, 'b': 23})
     h2 = Hasher()
     h2.update({'b': 23, 'a': 17})
     self.assertEqual(h1.digest(), h2.digest())
Exemplo n.º 14
0
 def file_hash(self, source, cu):
     m = Hasher()
     m.update(source)
     self.coverage.data.add_to_hash(cu.filename, m)
     return m.digest()
Exemplo n.º 15
0
 def file_hash(self, source, cu):
     m = Hasher()
     m.update(source)
     self.coverage.data.add_to_hash(cu.filename, m)
     return m.digest()