def test_reopen(self):
        """
        L{logfile.LogFile.reopen} allows to rename the currently used file and
        make L{logfile.LogFile} create a new file.
        """
        with contextlib.closing(logfile.LogFile(self.name, self.dir)) as log1:
            log1.write("hello1")
            savePath = os.path.join(self.dir, "save.log")
            os.rename(self.path, savePath)
            log1.reopen()
            log1.write("hello2")

        with open(self.path) as f:
            self.assertEqual(f.read(), "hello2")
        with open(savePath) as f:
            self.assertEqual(f.read(), "hello1")

        L{logfile.LogFile.reopen} allows to rename the currently used file and
        make L{logfile.LogFile} create a new file.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_logfile.py