MAINT: adding python3.13 to CI and fix any incompatibilities by bsipocz · Pull Request #260 · scientific-python/pytest-doctestplus

Conversation

@bsipocz

I see test failures locally, but there is also a puzzling one for older pythons that I see in my dev environment, but not when I run the tests from tox, so ultimately we may run into some new cross incompatibility with some other plugin.

(This will need a changelog once some actual code changes are needed for incompatibility fixes, but not until all the diff stays within the territory of the tests)

@bsipocz

The only test failures are coming from the diff generation; however, I also see some whitespace issues in astroquery that may be doctestplus related:
astropy/astroquery#3088

@pllim

Astroquery failure is unrelated to doctestplus, I commented on the Astroquery PR.

Should we ping seberg about the diff generation?

Thanks!

@bsipocz

Yeap, @seberg, would you mind having a look?

@bsipocz

@seberg

Hmmm, I suppose we have to read the actual indentation from the file then? Maybe something like:

diff --git a/pytest_doctestplus/plugin.py b/pytest_doctestplus/plugin.py
index f9c3a0c..5538c53 100644
--- a/pytest_doctestplus/plugin.py
+++ b/pytest_doctestplus/plugin.py
@@ -900,7 +900,8 @@ def write_modified_file(fname, new_fname, changes):
         lineno = change["test_lineno"] + change["example_lineno"]
         lineno += change["source"].count("\n")
 
-        indentation = " " * change["nindent"]
+        indentation = len(text[lineno-1]) - len(text[lineno-1].lstrip())
+        indentation = text[lineno-1][:indentation]
         want = indent(change["want"], indentation, lambda x: True)
         # Replace fully blank lines with the required `<BLANKLINE>`
         # (May need to do this also if line contains only whitespace)

EDIT: Sorry, first diff had a bug, this one should work.

@bsipocz

Thank you @seberg, it works like a dream.

pllim

Choose a reason for hiding this comment

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

Looks great. Thanks, all! I'll let you merge. :)