From d23cf2b1570122cdcd7dd5b4edaa614792417763 Mon Sep 17 00:00:00 2001 From: Doug Greiman Date: Wed, 2 Mar 2016 12:07:42 -0800 Subject: [PATCH] Restructure test so each scenario is independent. --- googletest/test/gtest_env_var_test.py | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/googletest/test/gtest_env_var_test.py b/googletest/test/gtest_env_var_test.py index 650b546a..424075cf 100755 --- a/googletest/test/gtest_env_var_test.py +++ b/googletest/test/gtest_env_var_test.py @@ -84,11 +84,10 @@ class GTestEnvVarTest(gtest_test_utils.TestCase): def testEnvVarAffectsFlag(self): """Tests that environment variable should affect the corresponding flag.""" - SetEnvVar('XML_OUTPUT_FILE', None) - TestFlag('break_on_failure', '1', '0') TestFlag('color', 'yes', 'auto') TestFlag('filter', 'FooTest.Bar', '*') + SetEnvVar('XML_OUTPUT_FILE', None) # For 'output' test TestFlag('output', 'xml:tmp/foo.xml', '') TestFlag('print_time', '0', '1') TestFlag('repeat', '999', '1') @@ -101,24 +100,18 @@ class GTestEnvVarTest(gtest_test_utils.TestCase): TestFlag('stack_trace_depth', '0', '100') def testXmlOutputFile(self): - """Test that $XML_OUTPUT_FILE affects the output flag.""" + """Tests that $XML_OUTPUT_FILE affects the output flag.""" - try: - # $XML_OUTPUT_FILE is overridden by $GTEST_OUTPUT - SetEnvVar('GTEST_OUTPUT', 'xml:tmp/foo.xml') - SetEnvVar('XML_OUTPUT_FILE', 'tmp/bar.xml') - AssertEq('xml:tmp/foo.xml', GetFlag('output')) + SetEnvVar('GTEST_OUTPUT', None) + SetEnvVar('XML_OUTPUT_FILE', 'tmp/bar.xml') + AssertEq('xml:tmp/bar.xml', GetFlag('output')) - # $XML_OUTPUT_FILE without $GTEST_OUTPUT sets output flag - SetEnvVar('GTEST_OUTPUT', None) - AssertEq('xml:tmp/bar.xml', GetFlag('output')) + def testXmlOutputFileOverride(self): + """Tests that $XML_OUTPUT_FILE is overridden by $GTEST_OUTPUT""" - # If neither set, flag has default value - SetEnvVar('XML_OUTPUT_FILE', None) - AssertEq('', GetFlag('output')) - finally: - SetEnvVar('GTEST_OUTPUT', None) - SetEnvVar('XML_OUTPUT_FILE', None) + SetEnvVar('GTEST_OUTPUT', 'xml:tmp/foo.xml') + SetEnvVar('XML_OUTPUT_FILE', 'tmp/bar.xml') + AssertEq('xml:tmp/foo.xml', GetFlag('output')) if __name__ == '__main__': gtest_test_utils.Main()