Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pathlib.Path instead of os.path.join in test_interactiveshell.py #13769

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 4 additions & 7 deletions IPython/core/tests/test_interactiveshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
import sys
import tempfile
import unittest
from pathlib import Path
from unittest import mock

from os.path import join

from IPython.core.error import InputRejected
from IPython.core.inputtransformer import InputTransformer
from IPython.core import interactiveshell
Expand Down Expand Up @@ -543,12 +542,10 @@ class TestSafeExecfileNonAsciiPath(unittest.TestCase):

@onlyif_unicode_paths
def setUp(self):
self.BASETESTDIR = tempfile.mkdtemp()
self.TESTDIR = join(self.BASETESTDIR, u"åäö")
self.BASETESTDIR = Path(tempfile.mkdtemp())
self.TESTDIR = self.BASETESTDIR / "åäö"
os.mkdir(self.TESTDIR)
with open(
join(self.TESTDIR, "åäötestscript.py"), "w", encoding="utf-8"
) as sfile:
with open(self.TESTDIR / "åäötestscript.py", "w", encoding="utf-8") as sfile:
Copy link
Contributor

Choose a reason for hiding this comment

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

Path objects have a method for writing text: path.write_text("text", encoding="utf-8")

Copy link
Author

Choose a reason for hiding this comment

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

You're right, didn't even think of that. I don't know what causes the FileNotFoundError though

sfile.write("pass\n")
self.oldpath = os.getcwd()
os.chdir(self.TESTDIR)
Expand Down