Comments (6)
I've merged the PR request, thanks for your comments!
I think I'll do a release later today.
from pytest-httpserver.
I've released 0.3.5.
I'm closing this issue in the hope that packages on pypi are also usable (I've already checked, but who knows..). :) If you see any problem, feel free to open a new issue.
Thanks for using this library!
from pytest-httpserver.
Hi,
This is the dup of #34. Please read my answer there.
As it came up from two different people, I think I'll add some basic support for this - however I still do not want to add any routing implementation as it would be a reimplementation of Flask. It means that the handlers will be looked up in a sequential order (in the same order as there were defined) with no respect of how narrow is the match.
What I mean by "basic" is the following:
- accepting a regexp object (eg the object returned by
re.compile()
), in such case the match will be performed. - accepting an URIPattern object, which would be defined as an abstract class, and it would have a
match()
method of it (eg. it would be handled in the same way as the regexp object).
The library itself would have no implementation of the URIPattern class, it would be up to the developer to implement something (eg prefix/suffix matches, glob matching, etc).
from pytest-httpserver.
Thanks for you answer! Just read your answer in #34 and it's great that we are able to do this 👍. But it might indeed be good to also implement a way to also accept regex as that seems a bit more user-friendly. If you need any help I'll be happy to assist implementing it 👌
from pytest-httpserver.
cc: @arturpat
I've submitted the PR #37 to implement pattern matching. Could you please have a look at it?
Obviously I accept any comments on the implementation and also I'm interested if this would make your life easier regarding this library. Having an isinstance on the object returned by re.compile is quite awkward but I could not find any better.
The key points are:
- regexps can be provided by re.compile (this is good for performance, but also to distinguish string from regexp)
- URIPattern is defined as abstract class, so it cannot be instantiated directly, but if you create a subclass and define the match() method, it will be used to match the URI. I was thinking about allowing providing of any callable, but this URIPattern can be parametrized (which will be true in 99% of cases, such as prefix match or glob match), and it is more type safe (in python term: easier to specify a pattern hint, better IDE support, etc)
I also kept the possibility to specify any object whose __eq__
is properly written as I suggested in #34, as I don't want to break any code (unless it is absolutely necessary).
from pytest-httpserver.
Hey,
thanks for getting back to this, that's cool! I will probably try to upgrade and battle-test your change in upcoming months :)
Thanks for developing this great library,
Artur
from pytest-httpserver.
Related Issues (20)
- Give a way to choose between listenning to IPV4 or IPV6 HOT 4
- Add client-side to the https code sample HOT 1
- Raise error if any request is received HOT 4
- Considering bringing plugin under pytest-dev HOT 2
- Add all the necessary imports in the code examples in the doc HOT 2
- Thread hang with hypothesis>=6.0.4 on Apple M1 Pro, Mac OS 12.6.2, Python>=3.10 HOT 11
- Can HTTPServer().handlers be modified from user code? HOT 3
- Recommendations for running both http (non-s) and https test within the same session HOT 2
- header auth matching breaks with Werkzeug>=2.3.0 HOT 5
- `werkzeug.urls` deprecation warnings with Werkzeug 2.3.0 HOT 2
- Twine dependency in 1.0.7 HOT 2
- Waiting without pytest and without starting the server HOT 6
- RFE: please start making github releases HOT 4
- Program stuck on server.stop() HOT 3
- Support Werkzeug 3.0 HOT 2
- Remove `<4` Python version constraint
- Not compatible with werkzeug >= 3.0 HOT 1
- Documentation: a small correction and adding a note for request handler HOT 5
- Add __repr__ to RequestHandler
- Add ability to simulate faults HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytest-httpserver.