#NEWLINE# def test_get_environ( ) : #NEWLINE# #INDENT# path = 'thing' #NEWLINE# defaults = { #NEWLINE# #INDENT# 'from_defaults' : 'b' , #NEWLINE# #UNINDENT# } #NEWLINE# original = { #NEWLINE# #INDENT# 'PATH' : os . path . pathsep . join ( [ 'crap' , 'bad_old_ve/bin' , 'junk' ] ) , #NEWLINE# 'from_passed' : 'x' , #NEWLINE# 'PYTHONHOME' : 'removeme' , #NEWLINE# 'VIRTUAL_ENV' : 'bad_old_ve' , #NEWLINE# #UNINDENT# } #NEWLINE# passed_environ = original . copy ( ) #NEWLINE# with FakeEnviron ( ) as os_environ , PatchedModule ( os . path , exists = ( lambda path : True ) ) : #NEWLINE# #INDENT# result = run . get_environ ( passed_environ , defaults , result ) #NEWLINE# assert ( len ( os_environ ) == 0 ) #NEWLINE# #UNINDENT# assert ( sorted ( original . items ( ) ) == sorted ( passed_environ . items ( ) ) ) #NEWLINE# assert ( result [ 'from_passed' ] == 'x' ) #NEWLINE# assert ( result [ 'from_defaults' ] == 'b' ) #NEWLINE# assert ( 'PYTHONHOME' not in result ) #NEWLINE# assert ( result [ 'PATH' ] == os . path . pathsep . join ( [ 'thing/bin' , 'crap' , 'junk' ] ) ) #NEWLINE# assert ( result [ 'VIRTUAL_ENV' ] == path )