##// END OF EJS Templates
Merge pull request #10316 from Carreau/autoreload-enum...
Thomas Kluyver -
r23399:b9370524 merge
parent child Browse files
Show More
@@ -0,0 +1,1 b''
1 * autoreload can now reload ``Enum``. See :ghissue:`10232` and :ghpull:`10316`
@@ -274,9 +274,10 b' def update_class(old, new):'
274 method code objects"""
274 method code objects"""
275 for key in list(old.__dict__.keys()):
275 for key in list(old.__dict__.keys()):
276 old_obj = getattr(old, key)
276 old_obj = getattr(old, key)
277
278 try:
277 try:
279 new_obj = getattr(new, key)
278 new_obj = getattr(new, key)
279 if old_obj == new_obj:
280 continue
280 except AttributeError:
281 except AttributeError:
281 # obsolete attribute: remove it
282 # obsolete attribute: remove it
282 try:
283 try:
@@ -15,6 +15,7 b''
15 import os
15 import os
16 import sys
16 import sys
17 import tempfile
17 import tempfile
18 import textwrap
18 import shutil
19 import shutil
19 import random
20 import random
20 import time
21 import time
@@ -23,6 +24,8 b' from io import StringIO'
23 import nose.tools as nt
24 import nose.tools as nt
24 import IPython.testing.tools as tt
25 import IPython.testing.tools as tt
25
26
27 from IPython.testing.decorators import skipif
28
26 from IPython.extensions.autoreload import AutoreloadMagics
29 from IPython.extensions.autoreload import AutoreloadMagics
27 from IPython.core.events import EventManager, pre_run_cell
30 from IPython.core.events import EventManager, pre_run_cell
28
31
@@ -126,6 +129,29 b' class Fixture(object):'
126 #-----------------------------------------------------------------------------
129 #-----------------------------------------------------------------------------
127
130
128 class TestAutoreload(Fixture):
131 class TestAutoreload(Fixture):
132
133 @skipif(sys.version_info < (3, 6))
134 def test_reload_enums(self):
135 import enum
136 mod_name, mod_fn = self.new_module(textwrap.dedent("""
137 from enum import Enum
138 class MyEnum(Enum):
139 A = 'A'
140 B = 'B'
141 """))
142 self.shell.magic_autoreload("2")
143 self.shell.magic_aimport(mod_name)
144 self.write_file(mod_fn, textwrap.dedent("""
145 from enum import Enum
146 class MyEnum(Enum):
147 A = 'A'
148 B = 'B'
149 C = 'C'
150 """))
151 with tt.AssertNotPrints(('[autoreload of %s failed:' % mod_name), channel='stderr'):
152 self.shell.run_code("pass") # trigger another reload
153
154
129 def _check_smoketest(self, use_aimport=True):
155 def _check_smoketest(self, use_aimport=True):
130 """
156 """
131 Functional test for the automatic reloader using either
157 Functional test for the automatic reloader using either
General Comments 0
You need to be logged in to leave comments. Login now