--cov as final element in addopts creates confusing behaviour

Abierto
#701 9 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
python
Área
testing-qa

Línea de trabajo

Start by reproducing the behavior with the shown pyproject.toml configuration and the commands pytest specific/file.py and pytest -s specific/file.py. Trace how the final --cov entry is combined with the selected test path; done means pytest specific/file.py runs only that file while coverage remains enabled.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Hi there,

I'm not sure this is a pytest bug but here it goes.

I have the following pyproject.toml configuration

[tool.pytest.ini_options]
testpaths = "test"
addopts = [
    "--import-mode=importlib",  # Recommended by pytest
    "--cov",
]

so I can easily use

pytest

to start my tests.

Now when I want to test only a specific file, doing

pytest specific/file.py

ignores the argument, while in the mean time, passing another optional argument such as the following

pytest -s specific/file.py

works perfectly as intended.

Am I missing a piece or is this a pytest-side problem?

Thanks in advance!

All the best.
Élie

Lenguaje dominante
Python
Estrellas
2.1k
Forks
256
Merge medio
6 d 10 min
PR fusionados (30 d)
2

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de pytest-dev/pytest-cov

Todos los issues de pytest-dev/pytest-cov

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.