##// END OF EJS Templates
Allow reloads of Enums....
Matthias Bussonnier -
Show More
@@ -0,0 +1,1 b''
1 * autoreload can now reload ``Enum``. See :ghissue:`10232` and :ghpull:`10316`
@@ -278,9 +278,10 b' def update_class(old, new):'
278 method code objects"""
278 method code objects"""
279 for key in list(old.__dict__.keys()):
279 for key in list(old.__dict__.keys()):
280 old_obj = getattr(old, key)
280 old_obj = getattr(old, key)
281
282 try:
281 try:
283 new_obj = getattr(new, key)
282 new_obj = getattr(new, key)
283 if old_obj == new_obj:
284 continue
284 except AttributeError:
285 except AttributeError:
285 # obsolete attribute: remove it
286 # obsolete attribute: remove it
286 try:
287 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