mindflayer / python-mocket

a socket mock framework - for all kinds of socket animals, web-clients included
BSD 3-Clause "New" or "Revised" License
279 stars 41 forks source link

Feature request: allow specifying exceptions to strict mode #218

Closed ento closed 5 months ago

ento commented 6 months ago

I'm trying to use a library that sends test stats to a remote server in the background [1], and tests that use Mocket in strict mode would fail intermittently when the library tries to make an HTTP request. I'd like to use strict mode to ensure no unexpected requests are made against the service a test is testing, while allowing test stats to be sent to the remote server.

A similar feature is supported (or may get supported) by some other libraries for mocking out HTTP requests when testing:

[1]: ddtrace, which sends telemetry data to Datadog's CI Visibility intake server

mindflayer commented 5 months ago

Hi @ento, please have a look at the PR I published before I actually merge it. I'll publish a new version straight after merging it.

By the way, I invited you to join the project as collaborator. Let me know if you like the idea.

mindflayer commented 5 months ago

I've just merged the PR, I hope you like the way I ended up refactoring your proposal. This is the new release shipping the feature you proposed: https://pypi.org/project/mocket/3.12.4/