コード例 #1
0
 def test_add_to_hash_with_lines(self):
     covdata = CoverageData()
     covdata.add_lines(LINES_1)
     hasher = mock.Mock()
     add_data_to_hash(covdata, "a.py", hasher)
     assert hasher.method_calls == [
         mock.call.update([1, 2]),  # lines
         mock.call.update(""),  # file_tracer name
     ]
コード例 #2
0
ファイル: test_data.py プロジェクト: hugovk/coveragepy
 def test_add_to_hash_with_lines(self):
     covdata = CoverageData()
     covdata.add_lines(LINES_1)
     hasher = mock.Mock()
     add_data_to_hash(covdata, "a.py", hasher)
     self.assertEqual(hasher.method_calls, [
         mock.call.update([1, 2]),   # lines
         mock.call.update(""),       # file_tracer name
     ])
コード例 #3
0
ファイル: test_data.py プロジェクト: ionelmc/coveragepy
 def test_add_to_lines_hash_with_missing_file(self):
     # https://bitbucket.org/ned/coveragepy/issues/403
     covdata = CoverageData()
     covdata.add_lines(LINES_1)
     hasher = mock.Mock()
     add_data_to_hash(covdata, "missing.py", hasher)
     self.assertEqual(hasher.method_calls, [
         mock.call.update([]),
         mock.call.update(None),
     ])
コード例 #4
0
 def test_add_to_lines_hash_with_missing_file(self):
     # https://github.com/nedbat/coveragepy/issues/403
     covdata = CoverageData()
     covdata.add_lines(LINES_1)
     hasher = mock.Mock()
     add_data_to_hash(covdata, "missing.py", hasher)
     assert hasher.method_calls == [
         mock.call.update([]),
         mock.call.update(None),
     ]
コード例 #5
0
 def test_add_to_hash_with_arcs(self):
     covdata = CoverageData()
     covdata.add_arcs(ARCS_3)
     covdata.add_file_tracers({"y.py": "hologram_plugin"})
     hasher = mock.Mock()
     add_data_to_hash(covdata, "y.py", hasher)
     assert hasher.method_calls == [
         mock.call.update([(-1, 17), (17, 23), (23, -1)]),  # arcs
         mock.call.update("hologram_plugin"),  # file_tracer name
     ]
コード例 #6
0
ファイル: test_data.py プロジェクト: hugovk/coveragepy
 def test_add_to_lines_hash_with_missing_file(self):
     # https://bitbucket.org/ned/coveragepy/issues/403
     covdata = CoverageData()
     covdata.add_lines(LINES_1)
     hasher = mock.Mock()
     add_data_to_hash(covdata, "missing.py", hasher)
     self.assertEqual(hasher.method_calls, [
         mock.call.update([]),
         mock.call.update(None),
     ])
コード例 #7
0
ファイル: test_data.py プロジェクト: hugovk/coveragepy
 def test_add_to_hash_with_arcs(self):
     covdata = CoverageData()
     covdata.add_arcs(ARCS_3)
     covdata.add_file_tracers({"y.py": "hologram_plugin"})
     hasher = mock.Mock()
     add_data_to_hash(covdata, "y.py", hasher)
     self.assertEqual(hasher.method_calls, [
         mock.call.update([(-1, 17), (17, 23), (23, -1)]),   # arcs
         mock.call.update("hologram_plugin"),                # file_tracer name
     ])
コード例 #8
0
ファイル: test_data.py プロジェクト: ionelmc/coveragepy
 def test_add_to_arcs_hash_with_missing_file(self):
     # https://bitbucket.org/ned/coveragepy/issues/403
     covdata = CoverageData()
     covdata.add_arcs(ARCS_3)
     covdata.add_file_tracers({"y.py": "hologram_plugin"})
     hasher = mock.Mock()
     add_data_to_hash(covdata, "missing.py", hasher)
     self.assertEqual(hasher.method_calls, [
         mock.call.update([]),
         mock.call.update(None),
     ])
コード例 #9
0
 def test_add_to_arcs_hash_with_missing_file(self):
     # https://github.com/nedbat/coveragepy/issues/403
     covdata = CoverageData()
     covdata.add_arcs(ARCS_3)
     covdata.add_file_tracers({"y.py": "hologram_plugin"})
     hasher = mock.Mock()
     add_data_to_hash(covdata, "missing.py", hasher)
     assert hasher.method_calls == [
         mock.call.update([]),
         mock.call.update(None),
     ]
コード例 #10
0
ファイル: test_data.py プロジェクト: hugovk/coveragepy
 def test_add_to_arcs_hash_with_missing_file(self):
     # https://bitbucket.org/ned/coveragepy/issues/403
     covdata = CoverageData()
     covdata.add_arcs(ARCS_3)
     covdata.add_file_tracers({"y.py": "hologram_plugin"})
     hasher = mock.Mock()
     add_data_to_hash(covdata, "missing.py", hasher)
     self.assertEqual(hasher.method_calls, [
         mock.call.update([]),
         mock.call.update(None),
     ])
コード例 #11
0
    def can_skip_file(self, data, fr, rootname):
        """Can we skip reporting this file?

        `data` is a CoverageData object, `fr` is a `FileReporter`, and
        `rootname` is the name being used for the file.
        """
        m = Hasher()
        m.update(fr.source().encode('utf-8'))
        add_data_to_hash(data, fr.filename, m)
        this_hash = m.hexdigest()

        that_hash = self.file_hash(rootname)

        if this_hash == that_hash:
            # Nothing has changed to require the file to be reported again.
            return True
        else:
            self.set_file_hash(rootname, this_hash)
            return False
コード例 #12
0
 def file_hash(self, source, fr):
     """Compute a hash that changes if the file needs to be re-reported."""
     m = Hasher()
     m.update(source)
     add_data_to_hash(self.data, fr.filename, m)
     return m.hexdigest()
コード例 #13
0
ファイル: html.py プロジェクト: hugovk/coveragepy
 def file_hash(self, source, fr):
     """Compute a hash that changes if the file needs to be re-reported."""
     m = Hasher()
     m.update(source)
     add_data_to_hash(self.data, fr.filename, m)
     return m.hexdigest()