Skip to content

Commit

Permalink
Merge pull request #12678 from rushabh-v/pl-ipdoctest
Browse files Browse the repository at this point in the history
use pathlib in testing/plugin/ipdoctest.py
  • Loading branch information
Carreau committed Oct 27, 2020
2 parents 21f8f14 + a42464a commit 6bef27a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions IPython/testing/plugin/ipdoctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

from inspect import getmodule

from pathlib import Path, PurePath

# We are overriding the default doctest runner, so we need to import a few
# things from doctest directly
from doctest import (REPORTING_FLAGS, REPORT_ONLY_FIRST_FAILURE,
Expand Down Expand Up @@ -687,9 +689,8 @@ def loadTestsFromFile(self, filename):
yield t
else:
if self.extension and anyp(filename.endswith, self.extension):
name = os.path.basename(filename)
with open(filename) as dh:
doc = dh.read()
name = PurePath(filename).name
doc = Path(filename).read_text()
test = self.parser.get_doctest(
doc, globs={'__file__': filename}, name=name,
filename=filename, lineno=0)
Expand Down

0 comments on commit 6bef27a

Please sign in to comment.