proxygen
gtest_env_var_test Namespace Reference

Classes

class  GTestEnvVarTest
 

Functions

def AssertEq (expected, actual)
 
def SetEnvVar (env_var, value)
 
def GetFlag (flag)
 
def TestFlag (flag, test_val, default_val)
 

Variables

string __author__ = 'wan@google.com (Zhanyong Wan)'
 
string IS_WINDOWS = 'nt'
 
string IS_LINUX = 'posix'
 
 COMMAND = gtest_test_utils.GetTestExecutablePath('gtest_env_var_test_')
 
 environ = os.environ.copy()
 

Function Documentation

def gtest_env_var_test.AssertEq (   expected,
  actual 
)

Definition at line 48 of file gtest_env_var_test.py.

Referenced by TestFlag(), gtest_env_var_test.GTestEnvVarTest.testXmlOutputFile(), and gtest_env_var_test.GTestEnvVarTest.testXmlOutputFileOverride().

48 def AssertEq(expected, actual):
49  if expected != actual:
50  print('Expected: %s' % (expected,))
51  print(' Actual: %s' % (actual,))
52  raise AssertionError
53 
54 
def AssertEq(expected, actual)
def gtest_env_var_test.GetFlag (   flag)
Runs gtest_env_var_test_ and returns its output.

Definition at line 64 of file gtest_env_var_test.py.

Referenced by TestFlag(), gtest_env_var_test.GTestEnvVarTest.testXmlOutputFile(), and gtest_env_var_test.GTestEnvVarTest.testXmlOutputFileOverride().

64 def GetFlag(flag):
65  """Runs gtest_env_var_test_ and returns its output."""
66 
67  args = [COMMAND]
68  if flag is not None:
69  args += [flag]
70  return gtest_test_utils.Subprocess(args, env=environ).output
71 
72 
def gtest_env_var_test.SetEnvVar (   env_var,
  value 
)
Sets the env variable to 'value'; unsets it when 'value' is None.

Definition at line 55 of file gtest_env_var_test.py.

Referenced by gtest_env_var_test.GTestEnvVarTest.testEnvVarAffectsFlag(), TestFlag(), gtest_env_var_test.GTestEnvVarTest.testXmlOutputFile(), and gtest_env_var_test.GTestEnvVarTest.testXmlOutputFileOverride().

55 def SetEnvVar(env_var, value):
56  """Sets the env variable to 'value'; unsets it when 'value' is None."""
57 
58  if value is not None:
59  environ[env_var] = value
60  elif env_var in environ:
61  del environ[env_var]
62 
63 
def SetEnvVar(env_var, value)
def gtest_env_var_test.TestFlag (   flag,
  test_val,
  default_val 
)
Verifies that the given flag is affected by the corresponding env var.

Definition at line 73 of file gtest_env_var_test.py.

References AssertEq(), GetFlag(), and SetEnvVar().

Referenced by gtest_env_var_test.GTestEnvVarTest.testEnvVarAffectsFlag().

73 def TestFlag(flag, test_val, default_val):
74  """Verifies that the given flag is affected by the corresponding env var."""
75 
76  env_var = 'GTEST_' + flag.upper()
77  SetEnvVar(env_var, test_val)
78  AssertEq(test_val, GetFlag(flag))
79  SetEnvVar(env_var, None)
80  AssertEq(default_val, GetFlag(flag))
81 
82 
def SetEnvVar(env_var, value)
def AssertEq(expected, actual)
def TestFlag(flag, test_val, default_val)

Variable Documentation

string gtest_env_var_test.__author__ = 'wan@google.com (Zhanyong Wan)'
private

Definition at line 34 of file gtest_env_var_test.py.

gtest_env_var_test.COMMAND = gtest_test_utils.GetTestExecutablePath('gtest_env_var_test_')

Definition at line 43 of file gtest_env_var_test.py.

gtest_env_var_test.environ = os.environ.copy()

Definition at line 45 of file gtest_env_var_test.py.

string gtest_env_var_test.IS_LINUX = 'posix'

Definition at line 41 of file gtest_env_var_test.py.

string gtest_env_var_test.IS_WINDOWS = 'nt'

Definition at line 40 of file gtest_env_var_test.py.