Skip to content

Conversation

thrau
Copy link
Contributor

@thrau thrau commented Jul 28, 2021

This PR fixes #63

I went for option 1 as proposed in #63

* I'm thinking about the effect of adding a catch all exception handler so every exception (including AssertionError of course) would be re-raised in the check_assertions() call. But I'm unsure about how it would break the code of the users. What do you think?

The way it is implemented now should not break user code, as exceptions from handlers are collected and then re-raised.

I also added __pycache__ to the .gitignore

Copy link
Owner

@csernazs csernazs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :) Kudos for adding thorough testing.

One thing I want to ask: why do you create a separate list for handler errors? Is this because of backward compatibility to guarantee that exceptions raised from the request handlers will still be ignored in check_assertions?

I'm thinking about adding one single check() function which would call these two method sequentially, so if someone is using a custom error handler they would benefit from both world. What do you think, would this make sense?

This would still keep the API compatible (check_assertions would not change) and if we document that the range of errors checked can change in the future, new calls could be added there later. Naming would be check() or check_all() or something like this.

@thrau
Copy link
Contributor Author

thrau commented Jul 28, 2021

sure, maybe the separation is not needed. happy to consolidate the two functions.

@csernazs
Copy link
Owner

I see the benefit of the separation (this wasn't true when I first saw your code, I admit). It provides backward compatibility and also provides some kind of differentiation of the "some expected result is not okay" between "some unhandled and nasty thing happened". AFAIK that's the difference between failure and error in the terms of testing and it is good to be separated.

@codecov
Copy link

codecov bot commented Jul 29, 2021

Codecov Report

Merging #64 (5158590) into master (d98a6c4) will increase coverage by 0.28%.
The diff coverage is 95.83%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #64      +/-   ##
==========================================
+ Coverage   94.05%   94.33%   +0.28%     
==========================================
  Files           3        3              
  Lines         437      459      +22     
==========================================
+ Hits          411      433      +22     
  Misses         26       26              
Impacted Files Coverage Δ
pytest_httpserver/httpserver.py 95.34% <95.83%> (+0.26%) ⬆️

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 d98a6c4...5158590. Read the comment docs.

@csernazs
Copy link
Owner

It seems that there's an unused import in your commit, could you fix that?

tests/test_handler_errors.py:5:1: F401 'pytest_httpserver.Error' imported but unused

@thrau
Copy link
Contributor Author

thrau commented Jul 29, 2021

i fixed the import error (my bad) and also added the check method, it's a good idea! now we have the separation and the consolidation :-)

@csernazs
Copy link
Owner

Thanks! :)

Just one little final ask: could you please squash these commits into one? It would look nicer. Then I will merge it I promise.

@thrau
Copy link
Contributor Author

thrau commented Jul 29, 2021

You could squash and merge the PR :-)
image

@csernazs csernazs merged commit 20e1454 into csernazs:master Jul 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

propagate assertion errors from custom handlers
2 participants