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 on test_deepreload.py #12591

Merged
merged 2 commits into from Oct 12, 2020
Merged
Changes from all 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
10 changes: 6 additions & 4 deletions IPython/lib/tests/test_deepreload.py
Expand Up @@ -4,28 +4,30 @@
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import os
from pathlib import Path

import nose.tools as nt

from IPython.utils.syspathcontext import prepended_to_syspath
from IPython.utils.tempdir import TemporaryDirectory
from IPython.lib.deepreload import reload as dreload


def test_deepreload():
"Test that dreload does deep reloads and skips excluded modules."
with TemporaryDirectory() as tmpdir:
with prepended_to_syspath(tmpdir):
with open(os.path.join(tmpdir, 'A.py'), 'w') as f:
tmpdirpath = Path(tmpdir)
with open(tmpdirpath / "A.py", "w") as f:
f.write("class Object(object):\n pass\n")
with open(os.path.join(tmpdir, 'B.py'), 'w') as f:
with open(tmpdirpath / "B.py", "w") as f:
f.write("import A\n")
import A
import B

# Test that A is not reloaded.
obj = A.Object()
dreload(B, exclude=['A'])
dreload(B, exclude=["A"])
nt.assert_true(isinstance(obj, A.Object))

# Test that A is reloaded.
Expand Down