Issue #79 new

save() prevents harvesting on stop()?

Zooko O'Whielacronx
created an issue


Looking at the source code of in search of a different bug, it appears to me that if you call {{{save()}}} then it will set {{{self._harvested = True}}} which means that if you then accumulate more measurements and then call {{{stop()}}} that the {{{stop()}}} will observe that {{{self._harvested}}} is already {{{True}}} and will then fail to harvest the new measurements.

Comments (3)

  1. Ned Batchelder repo owner

    Hmm, I changed this logic (for other reasons), but this series of calls still won't save data: start(), ..., save(), ... stop(). Is it important that it work? Do you have a use case for it?

  2. Ned Batchelder repo owner

    Here's the test I tried that demonstrated the problem to me. It fails:

        def test_start_save_stop(self):
            self.make_file("", """\
                code1 = 1
            self.make_file("", """\
                code2 = 1
                code2 = 2
            cov = coverage.coverage()
            _, statements, missing, _ = cov.analysis("")
            self.assertEqual(statements, [1])
            self.assertEqual(missing, [])
            _, statements, missing, _ = cov.analysis("")
            self.assertEqual(statements, [1, 2])
            self.assertEqual(missing, [])
  3. Log in to comment