1

我按照文档中的说明进行操作,我有这个:

import pytest
@pytest.mark.nondestructive
def test_nondestructive(selenium):
    selenium.get('http://www.example.com')

当我在命令行运行它时:

(venv) $ pytest --driver Firefox 
usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: unrecognized arguments: --cov --cov-report term-missing
  inifile: /Users/alexamil/WebstormProjects/oresoftware/sumanjs/sce/projects/python-basic/setup.cfg
  rootdir: /Users/alexamil/WebstormProjects/oresoftware/sumanjs/sce/projects/python-basic

你知道那个错误是关于什么的吗?

我也尝试过运行:

(venv) $ pytest --driver Firefox .

(venv) $ pytest --driver Firefox tests

测试在tests目录中,但我得到同样的错误。

我的 setup.cfg 看起来像:

# This file is used to configure your project.
# Read more about the various options under:
# http://setuptools.readthedocs.io/en/latest/setuptools.html#configuring-setup-using-setup-cfg-files

[metadata]
name = python-basic
description = Add a short description here!
author = Olegzandr VD
author-email = alex@oresoftware.com
license = mit
url = http://...
long-description = README.rst
# Change if running only on Windows, Mac or Linux (comma-separated)
platforms = any
# Add here all kinds of additional classifiers as defined under
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers =
    Development Status :: 4 - Beta
    Programming Language :: Python

[options]
zip_safe = False
packages = find:
include_package_data = True
package_dir =
    =src
# Add here dependencies of your project (semicolon-separated), e.g.
# install_requires = numpy; scipy
install_requires = 
# Add here test requirements (semicolon-separated)
tests_require = pytest; pytest-cov

[options.packages.find]
where = src
exclude =
    tests

[options.extras_require]
# Add here additional requirements for extra features, to install with:
# `pip install python-basic[PDF]` like:
# PDF = ReportLab; RXP

[test]
# py.test options when running `python setup.py test`
addopts = tests

[tool:pytest]
# Options for py.test:
# Specify command line options as you would do when invoking py.test directly.
# e.g. --cov-report html (or xml) for html/xml output or --junitxml junit.xml
# in order to write a coverage file that can be read by Jenkins.
addopts =
    --cov python_basic --cov-report term-missing
    --verbose
norecursedirs =
    dist
    build
    .tox

[aliases]
docs = build_sphinx
release = sdist bdist_wheel upload

[bdist_wheel]
# Use this option if your package is pure-python
universal = 1

[build_sphinx]
source_dir = docs
build_dir = docs/_build

[devpi:upload]
# Options for the devpi: PyPI server and packaging tool
# VCS export must be deactivated since we are using setuptools-scm
no-vcs = 1
formats = bdist_wheel

[flake8]
# Some sane defaults for the code style checker flake8
exclude =
    .tox
    build
    dist
    .eggs
    docs/conf.py

[pyscaffold]
# PyScaffold's parameters when the project was created.
# This will be used when updating. Do not change!
version = 3.0
package = python_basic

我的 setup.py 看起来像:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
    This file was generated with PyScaffold 3.0.
    PyScaffold helps you to put up the scaffold of your new Python project.
    Learn more under: http://pyscaffold.readthedocs.org/
"""

import sys
from setuptools import setup

# Add here console scripts and other entry points in ini-style format
entry_points = """
[console_scripts]
# script_name = python_basic.module:function
# For example:
# fibonacci = python_basic.skeleton:run
"""


def setup_package():
    needs_sphinx = {'build_sphinx', 'upload_docs'}.intersection(sys.argv)
    sphinx = ['sphinx'] if needs_sphinx else []
    setup(setup_requires=['pyscaffold>=3.0a0,<3.1a0'] + sphinx,
          entry_points=entry_points,
          use_pyscaffold=True)


if __name__ == "__main__":
    setup_package()

我认为罪魁祸首可能是 setup.cfg 中的这个,但我不知道该怎么办:

addopts =
    --cov python_basic --cov-report term-missing
    --verbose
4

0 回答 0