Source full path

Aperta
#573 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
testing

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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?

Lingua principale
Python
Stelle
2.1k
Fork
253
Merge medio
12g 4h
PR unite (30g)
4

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pytest-dev/pytest-cov

Tutte le issue di pytest-dev/pytest-cov

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.