Python 在 windows 上测试 3.4 的代码覆盖率

code Coverage for Python testing for 3.4 on windows

我想尝试使用 coverage.py 来测试我的 python 代码。我正在使用 Python 3.4,它在 Ned 的网站上说

The latest version is coverage.py 3.7.1, released 13 December 2013. It is supported on Python versions 2.3 through 3.4

但是,我找不到 3.4 的 Windows 设置。我必须安装 3.3 才能覆盖 运行 吗?因为我尝试使用 3.3.5 并且 3.3 的设置说它没有找到 Python 注册,并且 3.4 版本是否仅在非 Windows 平台上可用?

编辑:

也试过 3.3.0 它仍然给我一个 python not found in registry

结束重新安装Python 3.3.5 选择唯一我选项,选择所有用户将不会在您的用户中注册python,但会在机器中注册

我怀疑我 'installed' coveragepy 在我想要的目录中通过解压缩一个 zip 文件。它没有为任何特定版本安装。 coveragepy.main 在 Python 的多个版本上明确写入 运行。我 运行 它与我的(未注册的)存储库版本 3.4 一起使用 cover.bat 文件来测试建议的 idlelib 测试文件的覆盖率。

@echo off
rem Usage: cover fileName [test_ suffix] # proper case required by coveragepy
rem filename without .py, 2nd parameter if test is not test_filename
setlocal
set py=34\pcbuild\python_d
set src=idlelib.%1
if "%2" EQU "" set tst=34/Lib/idlelib/idle_test/test_%1.py
if "%2" NEQ "" set tst=34/Lib/idlelib/idle_test/test_%2.py

%py% coveragepy run --pylib --source=%src% %tst%
%py% coveragepy report --show-missing
%py% coveragepy html
htmlcov_Lib_idlelib_%1.html

我对 coveragepy 与自定义 .coveragerc 及以上相结合感到非常满意。