"python setup.py test" 与 "pytest {package}" 之间有什么区别?
what are the differences between "python setup.py test" vs "pytest {package}"?
我正在使用 GitHub 操作构建持续集成工作流。此工作流程将用于 运行 单元测试和测试构建状态。该工作流将由许多开发了 python 包的不同人员使用,因此我试图使其尽可能通用和模块化。我的目标是将 运行 单元测试的任务与测试这些包的构建状态分开,这引出了我的问题,命令 python setup.py test
和 pytest {package}
之间有什么区别?
具体来说,
使用命令 pytest {package}
进行单元测试 运行 是否会自动构建您的包,或者如果不构建您的包就无法 运行 进行单元测试?
我知道 setup.py 是 setuptools 的构建脚本,我已经阅读了命令 python setup.py test
的作用,它说它将: 运行 单元测试就地构建后。那么这个命令是不是默认使用pytest呢?
我还在 setuptools 文档中看到了构建命令,所以为了尝试回答我自己的问题,我会 pytest {package}
仅针对 运行ning 单元测试和 python setup.py build
来测试包的构建状态。
对吗?
非常感谢。
不回答差异,但是...
Warning: test
is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox.
-- setuptools documentation on the command "test
- Build package and run a unittest suite"
Does running unit tests with the command pytest {package}
automatically build your package?
不,它不需要,你不需要它 - 你不需要这个包来 运行 你的测试。
Is it not possible to run unit tests without building your package?
有可能。
I know that setup.py is the build script for setuptools and I have
read what the command python setup.py test
does and it says it will:
run unit tests after in-place build. So does this command use pytest
by default then?
它执行 运行 配置的测试,因此这取决于您的设置。如前所述,运行 python setup.py test
已被弃用,因此您通常不必担心这一点 - 直接在 CI 环境中使用 pytest
。请注意,尽管某些 Linux 发行版在部署时仍会默认执行 运行 此操作,因此如果您想分发您的软件包,您可能仍需要对其进行测试。
通过 setup
到 运行 pytest
你可能需要在你的 setup.py
:
中这样的东西
setup(
packages=find_packages(),
tests_require=['pytest'],
)
我正在使用 GitHub 操作构建持续集成工作流。此工作流程将用于 运行 单元测试和测试构建状态。该工作流将由许多开发了 python 包的不同人员使用,因此我试图使其尽可能通用和模块化。我的目标是将 运行 单元测试的任务与测试这些包的构建状态分开,这引出了我的问题,命令 python setup.py test
和 pytest {package}
之间有什么区别?
具体来说,
使用命令
pytest {package}
进行单元测试 运行 是否会自动构建您的包,或者如果不构建您的包就无法 运行 进行单元测试?我知道 setup.py 是 setuptools 的构建脚本,我已经阅读了命令
python setup.py test
的作用,它说它将: 运行 单元测试就地构建后。那么这个命令是不是默认使用pytest呢?
我还在 setuptools 文档中看到了构建命令,所以为了尝试回答我自己的问题,我会 pytest {package}
仅针对 运行ning 单元测试和 python setup.py build
来测试包的构建状态。
对吗?
非常感谢。
不回答差异,但是...
Warning:
test
is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox.
-- setuptools documentation on the command "test
- Build package and run a unittest suite"
Does running unit tests with the command pytest {package} automatically build your package?
不,它不需要,你不需要它 - 你不需要这个包来 运行 你的测试。
Is it not possible to run unit tests without building your package?
有可能。
I know that setup.py is the build script for setuptools and I have read what the command
python setup.py test
does and it says it will: run unit tests after in-place build. So does this command use pytest by default then?
它执行 运行 配置的测试,因此这取决于您的设置。如前所述,运行 python setup.py test
已被弃用,因此您通常不必担心这一点 - 直接在 CI 环境中使用 pytest
。请注意,尽管某些 Linux 发行版在部署时仍会默认执行 运行 此操作,因此如果您想分发您的软件包,您可能仍需要对其进行测试。
通过 setup
到 运行 pytest
你可能需要在你的 setup.py
:
setup(
packages=find_packages(),
tests_require=['pytest'],
)