<s> """<STR_LIT>""" <EOL> from __future__ import division , absolute_import <EOL> import sys <EOL> from twisted . python . filepath import FilePath <EOL> class TwistedModulesMixin : <EOL> """<STR_LIT>""" <EOL> def replaceSysPath ( self , sysPath ) : <EOL> """<STR_LIT>""" <EOL> originalSysPath = sys . path [ : ] <EOL> def cleanUpSysPath ( ) : <EOL> sys . path [ : ] = originalSysPath <EOL> self . addCleanup ( cleanUpSysPath ) <EOL> sys . path [ : ] = sysPath <EOL> def replaceSysModules ( self , sysModules ) : <EOL> """<STR_LIT>""" <EOL> originalSysModules = sys . modules . copy ( ) <EOL> def cleanUpSysModules ( ) : <EOL> sys . modules . clear ( ) <EOL> sys . modules . update ( originalSysModules ) <EOL> self . addCleanup ( cleanUpSysModules ) <EOL> sys . modules . clear ( ) <EOL> sys . modules . update ( sysModules ) <EOL> def pathEntryWithOnePackage ( self , pkgname = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> entry = FilePath ( self . mktemp ( ) ) <EOL> pkg = entry . child ( "<STR_LIT>" ) <EOL> pkg . makedirs ( ) <EOL> pkg . child ( "<STR_LIT>" ) . setContent ( b"<STR_LIT>" ) <EOL> return entry </s>
