当前位置: 首页>>代码示例>>Python>>正文


Python CoverageDataFiles.erase方法代码示例

本文整理汇总了Python中coverage.data.CoverageDataFiles.erase方法的典型用法代码示例。如果您正苦于以下问题:Python CoverageDataFiles.erase方法的具体用法?Python CoverageDataFiles.erase怎么用?Python CoverageDataFiles.erase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在coverage.data.CoverageDataFiles的用法示例。


在下文中一共展示了CoverageDataFiles.erase方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_erasing_parallel

# 需要导入模块: from coverage.data import CoverageDataFiles [as 别名]
# 或者: from coverage.data.CoverageDataFiles import erase [as 别名]
 def test_erasing_parallel(self):
     self.make_file("datafile.1")
     self.make_file("datafile.2")
     self.make_file(".coverage")
     data_files = CoverageDataFiles("datafile")
     data_files.erase(parallel=True)
     self.assert_doesnt_exist("datafile.1")
     self.assert_doesnt_exist("datafile.2")
     self.assert_exists(".coverage")
开发者ID:mociepka,项目名称:coveragepy,代码行数:11,代码来源:test_data.py

示例2: Coverage

# 需要导入模块: from coverage.data import CoverageDataFiles [as 别名]
# 或者: from coverage.data.CoverageDataFiles import erase [as 别名]

#.........这里部分代码省略.........
        Coverage measurement actually occurs in functions called after
        :meth:`start` is invoked.  Statements in the same scope as
        :meth:`start` won't be measured.

        Once you invoke :meth:`start`, you must also call :meth:`stop`
        eventually, or your process might not shut down cleanly.

        """
        self._init()
        if self.run_suffix:
            # Calling start() means we're running code, so use the run_suffix
            # as the data_suffix when we eventually save the data.
            self.data_suffix = self.run_suffix
        if self._auto_data:
            self.load()

        self.collector.start()
        self._started = True
        self._measured = True

    def stop(self):
        """Stop measuring code coverage."""
        if self._started:
            self.collector.stop()
        self._started = False

    def _atexit(self):
        """Clean up on process shutdown."""
        if self._started:
            self.stop()
        if self._auto_data:
            self.save()

    def erase(self):
        """Erase previously-collected coverage data.

        This removes the in-memory data collected in this session as well as
        discarding the data file.

        """
        self._init()
        self.collector.reset()
        self.data.erase()
        self.data_files.erase(parallel=self.config.parallel)

    def clear_exclude(self, which='exclude'):
        """Clear the exclude list."""
        self._init()
        setattr(self.config, which + "_list", [])
        self._exclude_regex_stale()

    def exclude(self, regex, which='exclude'):
        """Exclude source lines from execution consideration.

        A number of lists of regular expressions are maintained.  Each list
        selects lines that are treated differently during reporting.

        `which` determines which list is modified.  The "exclude" list selects
        lines that are not considered executable at all.  The "partial" list
        indicates lines with branches that are not taken.

        `regex` is a regular expression.  The regex is added to the specified
        list.  If any of the regexes in the list is found in a line, the line
        is marked for special treatment during reporting.

        """
开发者ID:Athsheep,项目名称:Flask_Web_Development,代码行数:70,代码来源:control.py

示例3: CoverageDataFilesTest

# 需要导入模块: from coverage.data import CoverageDataFiles [as 别名]
# 或者: from coverage.data.CoverageDataFiles import erase [as 别名]

#.........这里部分代码省略.........
        data_files2 = glob.glob(".coverage.*")
        self.assertEqual(len(data_files2), 2)

        # In addition to being different, the suffixes have the pid in them.
        self.assertTrue(all(str(os.getpid()) in fn for fn in data_files2))

    def test_combining(self):
        self.assert_doesnt_exist(".coverage.1")
        self.assert_doesnt_exist(".coverage.2")

        covdata1 = CoverageData()
        covdata1.set_lines(LINES_1)
        self.data_files.write(covdata1, suffix='1')
        self.assert_exists(".coverage.1")
        self.assert_doesnt_exist(".coverage.2")

        covdata2 = CoverageData()
        covdata2.set_lines(LINES_2)
        self.data_files.write(covdata2, suffix='2')
        self.assert_exists(".coverage.2")

        covdata3 = CoverageData()
        self.data_files.combine_parallel_data(covdata3)
        self.assert_line_counts(covdata3, SUMMARY_1_2)
        self.assert_measured_files(covdata3, MEASURED_FILES_1_2)
        self.assert_doesnt_exist(".coverage.1")
        self.assert_doesnt_exist(".coverage.2")

    def test_erasing(self):
        covdata1 = CoverageData()
        covdata1.set_lines(LINES_1)
        self.data_files.write(covdata1)

        covdata1.erase()
        self.assert_line_counts(covdata1, {})

        self.data_files.erase()
        covdata2 = CoverageData()
        self.data_files.read(covdata2)
        self.assert_line_counts(covdata2, {})

    def read_json_data_file(self, fname):
        """Read a JSON data file for testing the JSON directly."""
        with open(fname, 'r') as fdata:
            go_away = fdata.read(len(CoverageData._GO_AWAY))
            self.assertEqual(go_away, CoverageData._GO_AWAY)
            return json.load(fdata)

    def test_file_format(self):
        # Write with CoverageData, then read the JSON explicitly.
        covdata = CoverageData()
        covdata.set_lines(LINES_1)
        self.data_files.write(covdata)

        data = self.read_json_data_file(".coverage")

        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.assertNotIn('arcs', data)
        # If no file tracers were involved, there's no file_tracers entry.
        self.assertNotIn('file_tracers', data)

    def test_file_format_with_arcs(self):
开发者ID:ziadsawalha,项目名称:coveragepy,代码行数:70,代码来源:test_data.py


注:本文中的coverage.data.CoverageDataFiles.erase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。