Example #1
0
 def testFileRebuild(self):
     from twisted.python.rebuild import rebuild
     from twisted.python.util import sibpath
     import shutil, time
     shutil.copyfile(sibpath(__file__, "myrebuilder1.py"),
                     os.path.join(self.fakelibPath, "myrebuilder.py"))
     from twisted_rebuild_fakelib import myrebuilder
     a = myrebuilder.A()
     try:
         object
     except NameError:
         pass
     else:
         from twisted.test import test_rebuild
         b = myrebuilder.B()
         class C(myrebuilder.B):
             pass
         test_rebuild.C = C
         c = C()
     i = myrebuilder.Inherit()
     self.assertEquals(a.a(), 'a')
     time.sleep(1.1)
     shutil.copyfile(sibpath(__file__, "myrebuilder2.py"),
                     os.path.join(self.fakelibPath, "myrebuilder.py"))
     rebuild(myrebuilder)
     try:
         object
     except NameError:
         pass
     else:
         b2 = myrebuilder.B()
         self.assertEquals(b2.b(), 'c')
         self.assertEquals(b.b(), 'c')
     self.assertEquals(i.a(), 'd')
     self.assertEquals(a.a(), 'b')
Example #2
0
    def testFileRebuild(self):
        from twisted.python.rebuild import rebuild
        from twisted.python.util import sibpath
        import shutil, time
        shutil.copyfile(sibpath(__file__, "myrebuilder1.py"),
                        os.path.join(self.fakelibPath, "myrebuilder.py"))
        from twisted_rebuild_fakelib import myrebuilder
        a = myrebuilder.A()
        try:
            object
        except NameError:
            pass
        else:
            from twisted.test import test_rebuild
            b = myrebuilder.B()

            class C(myrebuilder.B):
                pass

            test_rebuild.C = C
            c = C()
        i = myrebuilder.Inherit()
        self.assertEquals(a.a(), 'a')
        # necessary because the file has not "changed" if a second has not gone
        # by in unix.  This sucks, but it's not often that you'll be doing more
        # than one reload per second.
        time.sleep(1.1)
        shutil.copyfile(sibpath(__file__, "myrebuilder2.py"),
                        os.path.join(self.fakelibPath, "myrebuilder.py"))
        rebuild(myrebuilder)
        try:
            object
        except NameError:
            pass
        else:
            b2 = myrebuilder.B()
            self.assertEquals(b2.b(), 'c')
            self.assertEquals(b.b(), 'c')
        self.assertEquals(i.a(), 'd')
        self.assertEquals(a.a(), 'b')
Example #3
0
 def testFileRebuild(self):
     from twisted.python.rebuild import rebuild
     from twisted.python.util import sibpath
     import shutil, time
     shutil.copyfile(sibpath(__file__, "myrebuilder1.py"),
                     os.path.join(self.fakelibPath, "myrebuilder.py"))
     from twisted_rebuild_fakelib import myrebuilder
     a = myrebuilder.A()
     try:
         object
     except NameError:
         pass
     else:
         from twisted.test import test_rebuild
         b = myrebuilder.B()
         class C(myrebuilder.B):
             pass
         test_rebuild.C = C
         c = C()
     i = myrebuilder.Inherit()
     self.assertEquals(a.a(), 'a')
     # necessary because the file has not "changed" if a second has not gone
     # by in unix.  This sucks, but it's not often that you'll be doing more
     # than one reload per second.
     time.sleep(1.1)
     shutil.copyfile(sibpath(__file__, "myrebuilder2.py"),
                     os.path.join(self.fakelibPath, "myrebuilder.py"))
     rebuild(myrebuilder)
     try:
         object
     except NameError:
         pass
     else:
         b2 = myrebuilder.B()
         self.assertEquals(b2.b(), 'c')
         self.assertEquals(b.b(), 'c')
     self.assertEquals(i.a(), 'd')
     self.assertEquals(a.a(), 'b')
Example #4
0
 def testRebuild(self):
     x = crash_test_dummy.X('a')
     x = [x]
     d = delay.Delayed()
     d.later(x[0].do, 1)
     d.run()
     d.run()
     d.run()
     
     d.later(x[0].do, 1)
     rebuild(crash_test_dummy,0)
     d.run()
     d.run()
     d.run()
     
     rebuild(thing,0)
     rebuild(server,0)
     assert f is crash_test_dummy.foo, 'huh?'
     #x[0].do()
     assert x[0].__class__ is crash_test_dummy.X, 'huh?'