I’m trying to use the StubBroker in unit tests as described in this section. I noticed one problem and wanted to raise it for discussion: Using the default middlewares
Note that the Prometheus middleware relies on various middleware hooks to set up and tear down — make sure that those hooks execute in the pytest context!
Issues[^discussion]
I’m trying to use the StubBroker in unit tests as described in this section. I noticed one problem and wanted to raise it for discussion: Using the default middlewares
https://github.com/Bogdanp/dramatiq/blob/a104a0bf999e6eb655c8d21d9d464e6697c7088b/dramatiq/middleware/__init__.py#L44-L47
for the
StubBroker
includes the Prometheus middleware which, when run in apytest
context, leaves the following errors after testing:I’ve not yet dug into this issue, but could probably take a look.
For the time being I work around this by removing the
Prometheus
middleware from theStubBroker
[^arg] as we discussed here:I’m unsure if that’s related to the mentioned Prometheus Gotchas.
What OS are you using?
macOS Ventura 13.2
What version of Dramatiq are you using?
What did you do?
See above.
What did you expect would happen?
No warnings from the Prometheus middleware.
What happened?
Warnings from the Prometheus middleware.
[^discussion]: I think the template needs updating as it still references the retired Reddit instead of the Groups.io link.
[^arg]: It might be a good idea to document the
middleware
arg for theStubBroker
here?