scipy / scipy_doctest

Floating-point aware doctesting
BSD 3-Clause "New" or "Revised" License
5 stars 4 forks source link

Replicate the user context manager #82

Closed Sheila-nk closed 1 year ago

Sheila-nk commented 1 year ago

https://github.com/scipy/scipy/blob/5b4b3ec030f4d27f6bb1b4c4ec53a92f83e648ef/tools/doctest_public_modules.py#L54

Sheila-nk commented 1 year ago

@ev-br Should this context manager: warnings_errors_and_rng be copied to scpdt's util.py module?

ev-br commented 1 year ago

Not sure. This looks somewhat scipy-specific. If the tool itself is meant to be cross-project, why others need to know about scipy-specific names and exceptions?

Off the cuff, this looks like a material for project-specific conftest.py (or however other means of project-specific configuration). WDYT?

Sheila-nk commented 1 year ago

That is true. I think we will know for sure if we need to implement a project-agnostic version of this after the integration.

ev-br commented 1 year ago

We do want a project-agnostic version + a clear way to add project specifics.

Sheila-nk commented 1 year ago

Okay, I think this is my next task then.

Sheila-nk commented 1 year ago

@ev-br I've noticed that this context manager is a combination of scpdt util's scipy_rndm_state and warnings_errors context managers but with a known_warnings dictionary for warnings that should be ignored.

So my goal is to ensure projects can use this context manager by specifying their own list of functions whose warnings should be ignored?

ev-br commented 1 year ago

The goal is that projects can specify the context where their doctests are run. This may or may not include warnings->errors, manipulations of the random state etc etc. This is up to a project.

What the cross-project tool needs to do is:

cf https://github.com/ev-br/scpdt/blob/main/scpdt/frontend.py#L247

EDIT: Maybe this logic needs to live in the runner which is responsible for actually running tests. Or an autofixture.