Ejemplo n.º 1
0
 def raw_data(self, filename):
     """Return the raw pickled data from `filename`."""
     if self.debug and self.debug.should('dataio'):
         self.debug.write("Reading data from %r" % (filename, ))
     with open(filename, 'rb') as fdata:
         data = pickle.load(fdata)
     return data
Ejemplo n.º 2
0
 def raw_data(self, filename):
     """Return the raw pickled data from `filename`."""
     if self.debug and self.debug.should('dataio'):
         self.debug.write("Reading data from %r" % (filename,))
     with open(filename, 'rb') as fdata:
         data = pickle.load(fdata)
     return data
Ejemplo n.º 3
0
    def read(self, directory):
        """Read the last status in `directory`."""
        usable = False
        try:
            status_file = os.path.join(directory, self.STATUS_FILE)
            fstatus = open(status_file, 'rb')
            try:
                status = pickle.load(fstatus)
            finally:
                fstatus.close()

        except (IOError, ValueError):
            usable = False
        else:
            usable = True
            if status['format'] != self.STATUS_FORMAT:
                usable = False
            elif status['version'] != coverage.__version__:
                usable = False

        if usable:
            self.files = status['files']
            self.settings = status['settings']
        else:
            self.reset()
Ejemplo n.º 4
0
 def raw_data(self, filename):
     """Return the raw pickled data from `filename`."""
     fdata = open(filename, 'rb')
     try:
         data = pickle.load(fdata)
     finally:
         fdata.close()
     return data
Ejemplo n.º 5
0
 def raw_data(self, filename):
     """Return the raw pickled data from `filename`."""
     fdata = open(filename, 'rb')
     try:
         data = pickle.load(fdata)
     finally:
         fdata.close()
     return data
Ejemplo n.º 6
0
 def raw_data(self, filename):
     """Return the raw pickled data from `filename`."""
     if self.debug and self.debug.should("dataio"):
         self.debug.write("Reading data from %r" % (filename,))
     fdata = open(filename, "rb")
     try:
         data = pickle.load(fdata)
     finally:
         fdata.close()
     return data
Ejemplo n.º 7
0
    def raw_data(self, filename):
        if self.debug and self.debug.should('dataio'):
            self.debug.write('Reading data from %r' % (filename,))
        fdata = open(filename, 'rb')
        try:
            data = pickle.load(fdata)
        finally:
            fdata.close()

        return data
Ejemplo n.º 8
0
 def raw_data(self, filename):
     """Return the raw pickled data from `filename`."""
     if self.debug and self.debug.should('dataio'):
         self.debug.write("Reading data from %r" % (filename, ))
     fdata = open(filename, 'rb')
     try:
         data = pickle.load(fdata)
     finally:
         fdata.close()
     return data
Ejemplo n.º 9
0
    def raw_data(self, filename):
        if self.debug and self.debug.should('dataio'):
            self.debug.write('Reading data from %r' % (filename, ))
        fdata = open(filename, 'rb')
        try:
            data = pickle.load(fdata)
        finally:
            fdata.close()

        return data
Ejemplo n.º 10
0
    def test_file_format_with_arcs(self):
        # Write with CoverageData, then read the pickle explicitly.
        covdata = CoverageData()
        covdata.add_arc_data(ARC_DATA_3)
        covdata.write()

        with open(".coverage", 'rb') as fdata:
            data = pickle.load(fdata)

        self.assertCountEqual(data['lines'].keys(), [])
        arcs = data['arcs']
        self.assertCountEqual(arcs['x.py'], X_PY_ARCS_3)
        self.assertCountEqual(arcs['y.py'], Y_PY_ARCS_3)
Ejemplo n.º 11
0
    def test_file_format_with_arcs(self):
        # Write with CoverageData, then read the pickle explicitly.
        covdata = CoverageData()
        covdata.add_arc_data(ARC_DATA_3)
        covdata.write()

        with open(".coverage", 'rb') as fdata:
            data = pickle.load(fdata)

        self.assertCountEqual(data['lines'].keys(), [])
        arcs = data['arcs']
        self.assertCountEqual(arcs['x.py'], X_PY_ARCS_3)
        self.assertCountEqual(arcs['y.py'], Y_PY_ARCS_3)
Ejemplo n.º 12
0
    def test_file_format(self):
        # Write with CoverageData, then read the pickle explicitly.
        covdata = CoverageData()
        covdata.add_line_data(DATA_1)
        covdata.write()

        with open(".coverage", 'rb') as fdata:
            data = pickle.load(fdata)

        lines = data['lines']
        self.assertCountEqual(lines.keys(), MEASURED_FILES_1)
        self.assertCountEqual(lines['a.py'], A_PY_LINES_1)
        self.assertCountEqual(lines['b.py'], B_PY_LINES_1)
        # If not measuring branches, there's no arcs entry.
        self.assertEqual(data.get('arcs', 'not there'), 'not there')
Ejemplo n.º 13
0
    def test_file_format(self):
        # Write with CoverageData, then read the pickle explicitly.
        covdata = CoverageData()
        covdata.add_line_data(DATA_1)
        covdata.write()

        with open(".coverage", 'rb') as fdata:
            data = pickle.load(fdata)

        lines = data['lines']
        self.assertCountEqual(lines.keys(), MEASURED_FILES_1)
        self.assertCountEqual(lines['a.py'], A_PY_LINES_1)
        self.assertCountEqual(lines['b.py'], B_PY_LINES_1)
        # If not measuring branches, there's no arcs entry.
        self.assertEqual(data.get('arcs', 'not there'), 'not there')
Ejemplo n.º 14
0
    def test_file_format_with_arcs(self):
        # Write with CoverageData, then read the pickle explicitly.
        covdata = CoverageData()
        covdata.add_arc_data(ARC_DATA_3)
        covdata.write()

        fdata = open(".coverage", 'rb')
        try:
            data = pickle.load(fdata)
        finally:
            fdata.close()

        self.assertSameElements(data['lines'].keys(), [])
        arcs = data['arcs']
        self.assertSameElements(arcs['x.py'], X_PY_ARCS_3)
        self.assertSameElements(arcs['y.py'], Y_PY_ARCS_3)
Ejemplo n.º 15
0
    def test_file_format_with_arcs(self):
        # Write with CoverageData, then read the pickle explicitly.
        covdata = CoverageData()
        covdata.add_arc_data(ARC_DATA_3)
        covdata.write()

        fdata = open(".coverage", 'rb')
        try:
            data = pickle.load(fdata)
        finally:
            fdata.close()

        self.assertSameElements(data['lines'].keys(), [])
        arcs = data['arcs']
        self.assertSameElements(arcs['x.py'], X_PY_ARCS_3)
        self.assertSameElements(arcs['y.py'], Y_PY_ARCS_3)
Ejemplo n.º 16
0
    def read(self, file_obj):
        """Read the coverage data from the given file object.

        Should only be used on an empty CoverageData object.

        """
        try:
            data = pickle.load(file_obj)
            if isinstance(data, dict):
                # Unpack the 'lines' item.
                self._lines = dict([(f, dict.fromkeys(linenos, None)) for f, linenos in iitems(data.get("lines", {}))])
                # Unpack the 'arcs' item.
                self._arcs = dict([(f, dict.fromkeys(arcpairs, None)) for f, arcpairs in iitems(data.get("arcs", {}))])
                self._plugins = data.get("plugins", {})
        except Exception:
            # TODO: this used to handle file-doesnt-exist problems.  Do we still need it?
            pass
Ejemplo n.º 17
0
    def test_file_format(self):
        # Write with CoverageData, then read the pickle explicitly.
        covdata = CoverageData()
        covdata.add_line_data(DATA_1)
        covdata.write()

        fdata = open(".coverage", "rb")
        try:
            data = pickle.load(fdata)
        finally:
            fdata.close()

        lines = data["lines"]
        self.assertSameElements(lines.keys(), MEASURED_FILES_1)
        self.assertSameElements(lines["a.py"], A_PY_LINES_1)
        self.assertSameElements(lines["b.py"], B_PY_LINES_1)
        # If not measuring branches, there's no arcs entry.
        self.assertEqual(data.get("arcs", "not there"), "not there")
Ejemplo n.º 18
0
    def test_file_format(self):
        # Write with CoverageData, then read the pickle explicitly.
        covdata = CoverageData()
        covdata.add_line_data(DATA_1)
        covdata.write()

        fdata = open(".coverage", 'rb')
        try:
            data = pickle.load(fdata)
        finally:
            fdata.close()

        lines = data['lines']
        self.assertSameElements(lines.keys(), EXECED_FILES_1)
        self.assertSameElements(lines['a.py'], A_PY_LINES_1)
        self.assertSameElements(lines['b.py'], B_PY_LINES_1)
        # If not measuring branches, there's no arcs entry.
        self.assertEqual(data.get('arcs', 'not there'), 'not there')
Ejemplo n.º 19
0
    def test_file_format(self):
        # Write with CoverageData, then read the pickle explicitly.
        covdata = CoverageData()
        covdata.add_line_data(DATA_1)
        covdata.write()

        fdata = open(".coverage", 'rb')
        try:
            data = pickle.load(fdata)
        finally:
            fdata.close()

        lines = data['lines']
        self.assertSameElements(lines.keys(), EXECED_FILES_1)
        self.assertSameElements(lines['a.py'], A_PY_LINES_1)
        self.assertSameElements(lines['b.py'], B_PY_LINES_1)
        # If not measuring branches, there's no arcs entry.
        self.assertEqual(data.get('arcs', 'not there'), 'not there')
Ejemplo n.º 20
0
    def read(self, directory):
        """Read the last status in `directory`."""
        usable = False
        try:
            status_file = os.path.join(directory, self.STATUS_FILE)
            status = pickle.load(open(status_file, "rb"))
        except IOError:
            usable = False
        else:
            usable = True
            if status['format'] != self.STATUS_FORMAT:
                usable = False
            elif status['version'] != coverage.__version__:
                usable = False

        if usable:
            self.files = status['files']
            self.settings = status['settings']
        else:
            self.reset()
Ejemplo n.º 21
0
    def read(self, directory):
        """Read the last status in `directory`."""
        usable = False
        try:
            status_file = os.path.join(directory, self.STATUS_FILE)
            status = pickle.load(open(status_file, "rb"))
        except IOError:
            usable = False
        else:
            usable = True
            if status['format'] != self.STATUS_FORMAT:
                usable = False
            elif status['version'] != coverage.__version__:
                usable = False

        if usable:
            self.files = status['files']
            self.settings = status['settings']
        else:
            self.reset()
Ejemplo n.º 22
0
    def read(self, directory):
        usable = False
        try:
            status_file = os.path.join(directory, self.STATUS_FILE)
            fstatus = open(status_file, 'rb')
            try:
                status = pickle.load(fstatus)
            finally:
                fstatus.close()

        except (IOError, ValueError):
            usable = False
        else:
            usable = True
            if status['format'] != self.STATUS_FORMAT:
                usable = False
            elif status['version'] != coverage.__version__:
                usable = False

        if usable:
            self.files = status['files']
            self.settings = status['settings']
        else:
            self.reset()
Ejemplo n.º 23
0
def pickle_read_raw_data(cls_unused, file_obj):
    """Replacement for CoverageData._read_raw_data."""
    return pickle.load(file_obj)