<s> from __future__ import print_function <EOL> import os <EOL> import subprocess <EOL> import sys <EOL> import pytest <EOL> vcvars_backup_files = { } <EOL> if sys . platform == "<STR_LIT:win32>" : <EOL> from conda_build . windows import ( build_vcvarsall_vs_path , <EOL> VCVARS64_VS9_BAT_PATH , <EOL> VS_TOOLS_PY_LOCAL_PATH , <EOL> VS_TOOLS_PY_COMMON_PATH ) <EOL> vcvars_backup_files = { "<STR_LIT>" . format ( version ) : [ build_vcvarsall_vs_path ( version ) ] <EOL> for version in [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] } <EOL> vcvars_backup_files [ '<STR_LIT>' ] . append ( VCVARS64_VS9_BAT_PATH ) <EOL> vcvars_backup_files [ "<STR_LIT>" ] = [ VS_TOOLS_PY_LOCAL_PATH ] <EOL> vcvars_backup_files [ "<STR_LIT>" ] = [ VS_TOOLS_PY_COMMON_PATH ] <EOL> vs9 = { key : vcvars_backup_files [ key ] for key in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] } <EOL> vs10 = { key : vcvars_backup_files [ key ] for key in [ '<STR_LIT>' ] } <EOL> vs14 = { key : vcvars_backup_files [ key ] for key in [ '<STR_LIT>' ] } <EOL> vcs = { "<STR_LIT>" : vs9 , "<STR_LIT>" : vs10 , "<STR_LIT>" : vs14 } <EOL> def write_bat_files ( good_locations ) : <EOL> for label , locations in vcvars_backup_files . items ( ) : <EOL> for location in locations : <EOL> assert not os . path . exists ( location ) <EOL> if not os . path . isdir ( os . path . dirname ( location ) ) : <EOL> os . makedirs ( os . path . dirname ( location ) ) <EOL> with open ( location , "<STR_LIT:w>" ) as f : <EOL> print ( "<STR_LIT>" . format ( location , int ( label not in good_locations ) ) ) <EOL> f . write ( "<STR_LIT>" ) <EOL> f . write ( "<STR_LIT>" . format ( int ( label not in good_locations ) ) ) <EOL> @ pytest . fixture ( scope = "<STR_LIT>" ) <EOL> def setup_teardown ( request ) : <EOL> def fin ( ) : <EOL> for locations in vcvars_backup_files . values ( ) : <EOL> for location in locations : <EOL> if os . path . exists ( location ) : <EOL> os . remove ( location ) <EOL> if os . path . exists ( location [ : - <NUM_LIT:1> ] + '<STR_LIT:k>' ) : <EOL> os . rename ( location [ : - <NUM_LIT:1> ] + '<STR_LIT:k>' , location ) <EOL> request . addfinalizer ( fin ) <EOL> for locations in vcvars_backup_files . values ( ) : <EOL> for location in locations : <EOL> if os . path . exists ( location ) : <EOL> os . rename ( location , location [ : - <NUM_LIT:1> ] + '<STR_LIT:k>' ) <EOL> return request <EOL> @ pytest . fixture ( scope = "<STR_LIT>" , params = vcvars_backup_files . keys ( ) ) <EOL> def compiler ( request , setup_teardown ) : <EOL> return request . param <EOL> @ pytest . fixture ( params = [ <NUM_LIT:32> , <NUM_LIT:64> ] ) <EOL> def bits ( request ) : <EOL> return request . param <EOL> @ pytest . mark . skipif ( sys . platform != "<STR_LIT:win32>" , reason = "<STR_LIT>" ) <EOL> @ pytest . mark . xfail ( reason = "<STR_LIT>" , strict = True ) <EOL> def test_activation_logic ( bits , compiler ) : <EOL> from conda_build . windows import msvc_env_cmd <EOL> write_bat_files ( [ ] ) <EOL> compiler_version = [ key for key in vcs if compiler in vcs [ key ] ] [ <NUM_LIT:0> ] <EOL> with open ( '<STR_LIT>' , "<STR_LIT:w>" ) as f : <EOL> f . write ( msvc_env_cmd ( bits , compiler_version ) ) <EOL> subprocess . check_call ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , shell = True ) <EOL> @ pytest . mark . skipif ( sys . platform != "<STR_LIT:win32>" , reason = "<STR_LIT>" ) <EOL> def test_activation ( bits , compiler ) : <EOL> write_bat_files ( [ compiler ] ) <EOL> from conda_build . windows import msvc_env_cmd , VS_VERSION_STRING <EOL> compiler_version = [ key for key in vcs if compiler in vcs [ key ] ] [ <NUM_LIT:0> ] <EOL> with open ( '<STR_LIT>' , "<STR_LIT:w>" ) as f : <EOL> f . write ( msvc_env_cmd ( bits , compiler_version ) ) <EOL> f . write ( '<STR_LIT>' . format ( compiler_version ) ) <EOL> f . write ( '<STR_LIT>' . format ( compiler_version . split ( '<STR_LIT:.>' ) [ <NUM_LIT:0> ] ) ) <EOL> f . write ( '<STR_LIT>' . format ( VS_VERSION_STRING [ compiler_version ] [ - <NUM_LIT:4> : ] ) ) <EOL> f . write ( '<STR_LIT>' . format ( VS_VERSION_STRING [ compiler_version ] + <EOL> { <NUM_LIT:64> : '<STR_LIT>' , <NUM_LIT:32> : '<STR_LIT>' } [ bits ] ) ) <EOL> try : <EOL> subprocess . check_call ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , shell = True ) <EOL> except subprocess . CalledProcessError : <EOL> print ( "<STR_LIT>" . format ( bits , compiler ) ) <EOL> raise <EOL> finally : <EOL> os . remove ( '<STR_LIT>' ) </s>
