Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6bef27a

Browse files
authored
Merge pull request #12678 from rushabh-v/pl-ipdoctest
use pathlib in testing/plugin/ipdoctest.py
2 parents 21f8f14 + a42464a commit 6bef27a

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

IPython/testing/plugin/ipdoctest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333

3434
from inspect import getmodule
3535

36+
from pathlib import Path, PurePath
37+
3638
# We are overriding the default doctest runner, so we need to import a few
3739
# things from doctest directly
3840
from doctest import (REPORTING_FLAGS, REPORT_ONLY_FIRST_FAILURE,
@@ -687,9 +689,8 @@ def loadTestsFromFile(self, filename):
687689
yield t
688690
else:
689691
if self.extension and anyp(filename.endswith, self.extension):
690-
name = os.path.basename(filename)
691-
with open(filename) as dh:
692-
doc = dh.read()
692+
name = PurePath(filename).name
693+
doc = Path(filename).read_text()
693694
test = self.parser.get_doctest(
694695
doc, globs={'__file__': filename}, name=name,
695696
filename=filename, lineno=0)

0 commit comments

Comments
 (0)