diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-11-28 07:08:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-28 07:08:12 (GMT) |
commit | 345aaa41766d5ec2e34cf08beb79307caf5fc5cf (patch) | |
tree | 530677a84bd2b0bf3bd2ef65a26f54f165c88139 /Lib/test | |
parent | ab87bcd91fdb5fddb0cea6f4a38ef9e6a679482b (diff) | |
download | cpython-345aaa41766d5ec2e34cf08beb79307caf5fc5cf.zip cpython-345aaa41766d5ec2e34cf08beb79307caf5fc5cf.tar.gz cpython-345aaa41766d5ec2e34cf08beb79307caf5fc5cf.tar.bz2 |
gh-51524: Fix bug when calling trace.CoverageResults with valid infile (GH-99629)
(cherry picked from commit 594de165bf2f21d6b28eb17003ea78fc20c0ffed)
Co-authored-by: Furkan Onder <furkanonder@protonmail.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_trace.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py index 7547855..3b3b291 100644 --- a/Lib/test/test_trace.py +++ b/Lib/test/test_trace.py @@ -1,4 +1,5 @@ import os +from pickle import dump import sys from test.support import captured_stdout from test.support.os_helper import (TESTFN, rmtree, unlink) @@ -407,6 +408,15 @@ class TestCoverage(unittest.TestCase): self.assertIn(modname, coverage) self.assertEqual(coverage[modname], (5, 100)) + def test_coverageresults_update(self): + # Update empty CoverageResults with a non-empty infile. + infile = TESTFN + '-infile' + with open(infile, 'wb') as f: + dump(({}, {}, {'caller': 1}), f, protocol=1) + self.addCleanup(unlink, infile) + results = trace.CoverageResults({}, {}, infile, {}) + self.assertEqual(results.callers, {'caller': 1}) + ### Tests that don't mess with sys.settrace and can be traced ### themselves TODO: Skip tests that do mess with sys.settrace when ### regrtest is invoked with -T option. |