##// END OF EJS Templates
Merge pull request #13206 from sgaist/nose_cleanup_first_step...
Merge pull request #13206 from sgaist/nose_cleanup_first_step Nose cleanup first step

File last commit:

r26913:a1ddd3bc
r26949:24290cb1 merge
Show More
test_deepreload.py
34 lines | 1.1 KiB | text/x-python | PythonLexer
# -*- coding: utf-8 -*-
"""Test suite for the deepreload module."""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
from pathlib import Path
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):
tmpdirpath = Path(tmpdir)
with open(tmpdirpath / "A.py", "w") as f:
f.write("class Object(object):\n pass\n")
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"])
assert isinstance(obj, A.Object) is True
# Test that A is reloaded.
obj = A.Object()
dreload(B)
assert isinstance(obj, A.Object) is False