首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >python setup.py测试在使用pytest时无法细化测试

python setup.py测试在使用pytest时无法细化测试
EN

Stack Overflow用户
提问于 2018-07-24 07:30:54
回答 1查看 1.4K关注 0票数 2

我的项目目录如下所示

代码语言:javascript
复制
setup.py
chtools/
  __init__.py
  perspective-tool
  lib/
  tests/
    __init__.py
    setup.cfg
    test_perspective.py

当我从我的项目目录(即与setup.py相同的级别)运行pytest时,一切都按预期运行。

代码语言:javascript
复制
(.venv) desktop:cloudhealth-tools$ pytest
platform linux -- Python 3.6.3, pytest-3.6.3, py-1.5.4, pluggy-0.6.0
rootdir: /home/jjk3/PycharmProjects/cloudhealth-tools, inifile:
collected 3 items                                                                                                                                                                                           

chtools/tests/test_perspective.py ... [100%]

但是当我运行python setup test时,它无法找到测试。

代码语言:javascript
复制
(.venv) desktop:cloudhealth-tools$ python setup.py test
running test
running egg_info
writing chtools.egg-info/PKG-INFO
writing dependency_links to chtools.egg-info/dependency_links.txt
writing entry points to chtools.egg-info/entry_points.txt
writing requirements to chtools.egg-info/requires.txt
writing top-level names to chtools.egg-info/top_level.txt
reading manifest file 'chtools.egg-info/SOURCES.txt'
writing manifest file 'chtools.egg-info/SOURCES.txt'
running build_ext

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK

我按照最简单的文档https://docs.pytest.org/en/2.9.1/goodpractices.html中的说明添加了setup_requirestests_require,但没有成功。

setup.py格式如下:

代码语言:javascript
复制
from setuptools import setup, find_packages

with open('README.md') as readme_file:
    readme = readme_file.read()

setup(name='chtools',
      version='1.0.6',
      description='Automation Tools for CloudHealth',
      url='https://github.com/bluechiptek/cloudhealth-tools',
      author='BlueChipTek',
      author_email='joe@bluechiptek.com',
      long_description_content_type='text/markdown',
      long_description=readme,
      license='GPLv3',
      packages=find_packages(),
      python_requires='>=3',
      install_requires=[
            'certifi==2018.1.18',
            'chardet==3.0.4',
            'idna==2.6',
            'PyYAML==3.13',
            'requests==2.18.4',
            'urllib3==1.22'
      ],
      setup_requires=['pytest-runner'],
      tests_require=['pytest'],
      entry_points={
            'console_scripts': ['perspective-tool=chtools.perspective_tool:main']
      },
      classifiers=[
            'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
            'Programming Language :: Python :: 3 :: Only'
      ]
      )

提前感谢您的帮助!

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51488471

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档