Source full path

Abierto
#573 4 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
25/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
python
Área
testing

Línea de trabajo

Reproduce the generated build/test-results/python.xml using the pytest.ini and .coveragerc configurations shown, then inspect how pytest-cov handles the source path in the XML report. Compare the reported absolute path with the desired project-relative src/main/python path; done means the report no longer includes the Jenkins workspace prefix.

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

Descripción

Team,

I'm trying to set up Python build in a project which is 'governed' by Gradle.
I'm also trying to use Gradle/Maven-conventional source path for Python files (src/main/python, src/test/python).

In general, everything works fine and as expected with one caveat (for me, specifically).
I'm using pytest with pytest.ini where I set pytest-cov configuration with the following:

[pytest]
norecursedirs = .gradle/** gradle/** build/** out/** **/src/main/python/**
python_files = *_spec.py
python_functions = feature_*
pythonpath = src/main/python
addopts = --cov=src/main/python --cov-config=.coveragerc --cov-report xml:build/test-results/python.xml --cov-report html:build/reports/tests/python src/test/python

and corresponding .coveragerc:

[run]
omit = **/test/**
source = src/test/python

The problem I'm having is the path to the source files in the python.xml test coverage report.
It seems to prefix the src/main/python with the output of the pwd command and I'm effectively getting stuff like

<sources>
   <source>/home/jenkins/workspace/pipeline-name-here/application/src/main/python</source>
</sources>

where /home/jenkins/workspace/pipeline-name-here/application/ is that annoying prefix I'm need to get rid of.

My Gradle folder structure (w/service folders omitted) is like

|-- Git-name-of-the-project
   |--- ansible
     |--- ansible files
   |--- application
     |--- <temp build-related folders>
     |--- src
             |--- main
                 |--- python
                     |--- python-file.py
     |--- gradlew <etc>
     |--- .coveragerc
     |--- pytest.ini 

Any suggestions?

Lenguaje dominante
Python
Estrellas
2.1k
Forks
253
Merge medio
12 d 4 h
PR fusionados (30 d)
4

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.