2
私は小さなPythonパッケージ(python-telegram-bot
に基づいている)を開始し、テストベースの開発をしたいと思っています。そこで私はpy.test
をいくつかの基本的なユニットテストで活性化しました。py.testでsetup.pyの "No commands supplied"を避ける方法
しかし、私はいつもsetup.py
にエラーを受け取ります。なぜなら、それは引数としてコマンドを必要としますが、py.test
は何も提供しないからです。私はそれが本当にsetup.py
に誤りはなく、むしろpy.test
ランニングでの問題ではないことを理解
=========================== test session starts ==========================
platform darwin -- Python 3.6.0, pytest-3.0.6, py-1.4.32, pluggy-0.4.0
rootdir: ~/dev/project, inifile: pytest.ini
collected 4 items/1 errors
================================= ERRORS =================================
________________________ ERROR collecting setup.py _______________________
/usr/local/Cellar/python3/3.6.0_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/core.py:134: in setup
ok = dist.parse_command_line()
../../../.virtualenvs/project/lib/python3.6/site-packages/setuptools/dist.py:358: in parse_command_line
result = _Distribution.parse_command_line(self)
/usr/local/Cellar/python3/3.6.0_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py:490: in parse_command_line
raise DistutilsArgError("no commands supplied")
E distutils.errors.DistutilsArgError: no commands supplied
During handling of the above exception, another exception occurred:
setup.py:58: in <module>
tests_require=test_requirements
/usr/local/Cellar/python3/3.6.0_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/core.py:136: in setup
raise SystemExit(gen_usage(dist.script_name) + "\nerror: %s" % msg)
E SystemExit: usage: py.test [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
E or: py.test --help [cmd1 cmd2 ...]
E or: py.test --help-commands
E or: py.test cmd --help
E
E error: no commands supplied
!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!
========================= 1 error in 1.04 seconds ========================
:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from setuptools import setup
requirements = [
'python-telegram-bot>=5.3.0'
]
test_requirements = [
'pytest>=3.0'
]
setup(
name='project',
version='0.1.0',
packages=[
'project',
],
package_dir={'project':
'project'},
entry_points={
'console_scripts': [
'project=project.cli:main'
]
},
include_package_data=True,
install_requires=requirements,
license="MIT license",
zip_safe=False,
test_suite='tests',
tests_require=test_requirements
)
そしてpy.test
結果:ここで
はsetup.py
の短縮バージョンですsetup.py
何も引数なし...しかし、私はこのエラーが私のテストを台無しにするのを避けることができますか?
コードを表示できますか? –
@NilsWerner:ありがとう。 'setup.py'の簡略版を追加しました –
pytest configに' python_files = * 'のようなものを設定しましたか? –