smarie / python-pytest-harvest

Store data created during your `pytest` tests execution, and retrieve it at the end of the session, e.g. for applicative benchmarking purposes.
https://smarie.github.io/python-pytest-harvest/
BSD 3-Clause "New" or "Revised" License
61 stars 8 forks source link

fix variable scoping error #35

Closed larsks closed 4 years ago

larsks commented 4 years ago

Due to the way the variable used in except <exception> as <variable> is handled [1], it won't be in the scope of a function defined with the except block. It is necessary to first save the value to another variable. Without this, execution that hits these except blocks will fail with:

NameError: name 'e' is not defined

[1] https://docs.python.org/3/reference/compound_stmts.html#the-try-statement

codecov-io commented 4 years ago

Codecov Report

Merging #35 into master will decrease coverage by 0.2%. The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #35      +/-   ##
==========================================
- Coverage   94.46%   94.26%   -0.21%     
==========================================
  Files          29       29              
  Lines         940      942       +2     
==========================================
  Hits          888      888              
- Misses         52       54       +2
Impacted Files Coverage Δ
pytest_harvest/plugin.py 82.75% <0%> (-2.96%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update cd4b9d1...cc30149. Read the comment docs.

smarie commented 4 years ago

Indeed :) thanks for the careful review @larsks