def replaceSysPath(self, sysPath):
        """
        Replace sys.path, for the duration of the test, with the given value.
        """
        originalSysPath = sys.path[:]
        def cleanUpSysPath():
            sys.path[:] = originalSysPath
        self.addCleanup(cleanUpSysPath)
        sys.path[:] = sysPath

        Replace sys.path, for the duration of the test, with the given value.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/modules_helpers.py