def test_parent_function(self): SAMPLE_CODE1 = """ class B(object): def foo(self): return 0 class C(B): def call(self): return self.foo() """ # Creating a new class and using it from old class SAMPLE_CODE2 = """ class B(object): def foo(self): return 0 def bar(self): return 'bar' class C(B): def call(self): return self.bar() """ self.make_mod(sample=SAMPLE_CODE1) import x # @UnresolvedImport call = x.C().call self.assertEqual(call(), 0) self.make_mod(sample=SAMPLE_CODE2) pydevd_reload.xreload(x) self.assertEqual(call(), 'bar')
def test_pydevd_reload2(self): self.make_mod() import x # @UnresolvedImport c = x.C() cfoo = c.foo self.assertEqual(0, c.foo()) self.assertEqual(0, cfoo()) self.make_mod(repl="0", subst='1') pydevd_reload.xreload(x) self.assertEqual(1, c.foo()) self.assertEqual(1, cfoo())
def test_create_class2(self): SAMPLE_CODE1 = """ class C(object): def foo(self): return 0 """ # Creating a new class and using it from old class SAMPLE_CODE2 = """ class B(object): pass class C(object): def foo(self): return B """ self.make_mod(sample=SAMPLE_CODE1) import x # @UnresolvedImport foo = x.C().foo self.assertEqual(foo(), 0) self.make_mod(sample=SAMPLE_CODE2) pydevd_reload.xreload(x) self.assertEqual(foo().__name__, 'B')