summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.rst2
-rw-r--r--coverage/backward.py6
-rw-r--r--coverage/pickle2json.py47
-rw-r--r--tests/test_pickle2json.py55
4 files changed, 2 insertions, 108 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index 11644871..1b6c8ddb 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -21,6 +21,8 @@ Unreleased
- HTML files no longer have trailing and extra whitespace.
+- pickle2json has been removed.
+
.. _Bitbucket: https://bitbucket.org/ned/coveragepy
.. _GitHub: https://github.com/nedbat/coveragepy
diff --git a/coverage/backward.py b/coverage/backward.py
index 5f59b23f..b43e35f3 100644
--- a/coverage/backward.py
+++ b/coverage/backward.py
@@ -38,12 +38,6 @@ try:
except NameError:
unicode_class = str
-# Where do pickles come from?
-try:
- import cPickle as pickle
-except ImportError:
- import pickle
-
# range or xrange?
try:
range = xrange # pylint: disable=redefined-builtin
diff --git a/coverage/pickle2json.py b/coverage/pickle2json.py
deleted file mode 100644
index 006558f1..00000000
--- a/coverage/pickle2json.py
+++ /dev/null
@@ -1,47 +0,0 @@
-# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
-# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt
-
-"""Convert pickle to JSON for coverage.py."""
-
-from coverage.backward import pickle
-from coverage.data import CoverageData
-
-
-def pickle_read_raw_data(cls_unused, file_obj):
- """Replacement for CoverageData._read_raw_data."""
- return pickle.load(file_obj)
-
-
-def pickle2json(infile, outfile):
- """Convert a coverage.py 3.x pickle data file to a 4.x JSON data file."""
- try:
- old_read_raw_data = CoverageData._read_raw_data
- CoverageData._read_raw_data = pickle_read_raw_data
-
- covdata = CoverageData()
-
- with open(infile, 'rb') as inf:
- covdata.read_fileobj(inf)
-
- covdata.write_file(outfile)
- finally:
- CoverageData._read_raw_data = old_read_raw_data
-
-
-if __name__ == "__main__":
- from optparse import OptionParser
-
- parser = OptionParser(usage="usage: %s [options]" % __file__)
- parser.description = "Convert .coverage files from pickle to JSON format"
- parser.add_option(
- "-i", "--input-file", action="store", default=".coverage",
- help="Name of input file. Default .coverage",
- )
- parser.add_option(
- "-o", "--output-file", action="store", default=".coverage",
- help="Name of output file. Default .coverage",
- )
-
- (options, args) = parser.parse_args()
-
- pickle2json(options.input_file, options.output_file)
diff --git a/tests/test_pickle2json.py b/tests/test_pickle2json.py
deleted file mode 100644
index 37886bac..00000000
--- a/tests/test_pickle2json.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
-# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt
-
-"""Tests for coverage.pickle2json"""
-
-from coverage.backward import pickle, iitems
-from coverage.data import CoverageData
-from coverage.pickle2json import pickle2json
-
-from tests.coveragetest import CoverageTest
-from tests.test_data import DataTestHelpers, LINES_1, ARCS_3
-
-
-class Pickle2JsonTestInTempDir(DataTestHelpers, CoverageTest):
- """Tests pickle2json.py."""
-
- no_files_in_temp_dir = True
-
- def write_pickled_file(self, covdata, filename):
- """Write coverage data as pickled `filename`."""
- # Create the file data.
- file_data = {}
-
- if covdata._arcs:
- file_data['arcs'] = dict((f, list(amap)) for f, amap in iitems(covdata._arcs))
- else:
- file_data['lines'] = dict((f, list(lmap)) for f, lmap in iitems(covdata._lines))
-
- # Write the pickle to the file.
- with open(filename, 'wb') as file_obj:
- pickle.dump(file_data, file_obj, 2)
-
- def test_read_write_lines_pickle(self):
- # Test the old pickle format.
- covdata1 = CoverageData()
- covdata1.add_lines(LINES_1)
- self.write_pickled_file(covdata1, "lines.pkl")
-
- pickle2json("lines.pkl", "lines.json")
-
- covdata2 = CoverageData()
- covdata2.read_file("lines.json")
- self.assert_lines1_data(covdata2)
-
- def test_read_write_arcs_pickle(self):
- # Test the old pickle format.
- covdata1 = CoverageData()
- covdata1.add_arcs(ARCS_3)
- self.write_pickled_file(covdata1, "arcs.pkl")
-
- pickle2json("arcs.pkl", "arcs.json")
-
- covdata2 = CoverageData()
- covdata2.read_file("arcs.json")
- self.assert_arcs3_data(covdata2)