Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 41 additions & 41 deletions testing/framework/TestCmdTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def test_atexit(self):
import sys
import TestCmd

sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path

@atexit.register
def cleanup():
Expand Down Expand Up @@ -415,7 +415,7 @@ def test_diff_re(self):
def test_diff_custom_function(self):
"""Test diff() using a custom function"""
self.popen_python("""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
def my_diff(a, b):
return [
Expand All @@ -440,7 +440,7 @@ def my_diff(a, b):

def test_diff_string(self):
self.popen_python("""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
test = TestCmd.TestCmd(diff = 'diff_re')
test.diff("a\\nb1\\nc\\n", "a\\nb2\\nc\\n", 'STDOUT')
Expand All @@ -457,7 +457,7 @@ def test_diff_string(self):
def test_error(self):
"""Test handling a compilation error in TestCmd.diff_re()"""
script_input = """import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
assert TestCmd.diff_re([r"a.*(e"], ["abcde"])
sys.exit(0)
Expand All @@ -472,7 +472,7 @@ def test_error(self):
def test_simple_diff_static_method(self):
"""Test calling the TestCmd.TestCmd.simple_diff() static method"""
self.popen_python("""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
result = TestCmd.TestCmd.simple_diff(['a', 'b', 'c', 'e', 'f1'],
['a', 'c', 'd', 'e', 'f2'])
Expand All @@ -485,7 +485,7 @@ def test_simple_diff_static_method(self):
def test_context_diff_static_method(self):
"""Test calling the TestCmd.TestCmd.context_diff() static method"""
self.popen_python("""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
result = TestCmd.TestCmd.context_diff(['a\\n', 'b\\n', 'c\\n', 'e\\n', 'f1\\n'],
['a\\n', 'c\\n', 'd\\n', 'e\\n', 'f2\\n'])
Expand Down Expand Up @@ -514,7 +514,7 @@ def test_context_diff_static_method(self):
def test_unified_diff_static_method(self):
"""Test calling the TestCmd.TestCmd.unified_diff() static method"""
self.popen_python("""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
result = TestCmd.TestCmd.unified_diff(['a\\n', 'b\\n', 'c\\n', 'e\\n', 'f1\\n'],
['a\\n', 'c\\n', 'd\\n', 'e\\n', 'f2\\n'])
Expand All @@ -538,7 +538,7 @@ def test_unified_diff_static_method(self):
def test_diff_re_static_method(self):
"""Test calling the TestCmd.TestCmd.diff_re() static method"""
self.popen_python("""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
result = TestCmd.TestCmd.diff_re(['a', 'b', 'c', '.', 'f1'],
['a', 'c', 'd', 'e', 'f2'])
Expand Down Expand Up @@ -567,7 +567,7 @@ class diff_stderr_TestCase(TestCmdTestCase):
def test_diff_stderr_default(self):
"""Test diff_stderr() default behavior"""
self.popen_python(r"""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
test = TestCmd.TestCmd()
test.diff_stderr('a\nb1\nc\n', 'a\nb2\nc\n')
Expand All @@ -584,7 +584,7 @@ def test_diff_stderr_not_affecting_diff_stdout(self):
"""Test diff_stderr() not affecting diff_stdout() behavior"""
self.popen_python(r"""
import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
test = TestCmd.TestCmd(diff_stderr='diff_re')
print("diff_stderr:")
Expand All @@ -605,7 +605,7 @@ def test_diff_stderr_not_affecting_diff_stdout(self):
def test_diff_stderr_custom_function(self):
"""Test diff_stderr() using a custom function"""
self.popen_python(r"""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
def my_diff(a, b):
return ["a:"] + a + ["b:"] + b
Expand All @@ -623,7 +623,7 @@ def my_diff(a, b):
def test_diff_stderr_TestCmd_function(self):
"""Test diff_stderr() using a TestCmd function"""
self.popen_python(r"""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
test = TestCmd.TestCmd(diff_stderr = TestCmd.diff_re)
test.diff_stderr('a\n.\n', 'b\nc\n')
Expand All @@ -639,7 +639,7 @@ def test_diff_stderr_TestCmd_function(self):
def test_diff_stderr_static_method(self):
"""Test diff_stderr() using a static method"""
self.popen_python(r"""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
test = TestCmd.TestCmd(diff_stderr=TestCmd.TestCmd.diff_re)
test.diff_stderr('a\n.\n', 'b\nc\n')
Expand All @@ -655,7 +655,7 @@ def test_diff_stderr_static_method(self):
def test_diff_stderr_string(self):
"""Test diff_stderr() using a string to fetch the diff method"""
self.popen_python(r"""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
test = TestCmd.TestCmd(diff_stderr='diff_re')
test.diff_stderr('a\n.\n', 'b\nc\n')
Expand All @@ -674,7 +674,7 @@ class diff_stdout_TestCase(TestCmdTestCase):
def test_diff_stdout_default(self):
"""Test diff_stdout() default behavior"""
self.popen_python(r"""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
test = TestCmd.TestCmd()
test.diff_stdout('a\nb1\nc\n', 'a\nb2\nc\n')
Expand All @@ -691,7 +691,7 @@ def test_diff_stdout_not_affecting_diff_stderr(self):
"""Test diff_stdout() not affecting diff_stderr() behavior"""
self.popen_python(r"""
import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
test = TestCmd.TestCmd(diff_stdout='diff_re')
print("diff_stdout:")
Expand All @@ -712,7 +712,7 @@ def test_diff_stdout_not_affecting_diff_stderr(self):
def test_diff_stdout_custom_function(self):
"""Test diff_stdout() using a custom function"""
self.popen_python(r"""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
def my_diff(a, b):
return ["a:"] + a + ["b:"] + b
Expand All @@ -730,7 +730,7 @@ def my_diff(a, b):
def test_diff_stdout_TestCmd_function(self):
"""Test diff_stdout() using a TestCmd function"""
self.popen_python(r"""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
test = TestCmd.TestCmd(diff_stdout = TestCmd.diff_re)
test.diff_stdout('a\n.\n', 'b\nc\n')
Expand All @@ -746,7 +746,7 @@ def test_diff_stdout_TestCmd_function(self):
def test_diff_stdout_static_method(self):
"""Test diff_stdout() using a static method"""
self.popen_python(r"""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
test = TestCmd.TestCmd(diff_stdout=TestCmd.TestCmd.diff_re)
test.diff_stdout('a\n.\n', 'b\nc\n')
Expand All @@ -762,7 +762,7 @@ def test_diff_stdout_static_method(self):
def test_diff_stdout_string(self):
"""Test diff_stdout() using a string to fetch the diff method"""
self.popen_python(r"""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
test = TestCmd.TestCmd(diff_stdout='diff_re')
test.diff_stdout('a\n.\n', 'b\nc\n')
Expand All @@ -788,7 +788,7 @@ def _test_it(cwd, tempdir, condition, preserved):
'no_result': "NO RESULT for test at line 5 of <stdin>\n"}
global ExitError
input = """import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
test = TestCmd.TestCmd(workdir = '%s')
test.%s()
Expand Down Expand Up @@ -863,29 +863,29 @@ def test_fail_test(self):
# Everything before this prepared our "source directory."
# Now do the real test.
self.popen_python("""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
TestCmd.fail_test(condition = 1)
""" % self.orig_cwd, status = 1, stderr = "FAILED test at line 4 of <stdin>\n")

self.popen_python("""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
test = TestCmd.TestCmd(program = 'run', interpreter = 'python', workdir = '')
test.run()
test.fail_test(condition = (test.status == 0))
""" % self.orig_cwd, status = 1, stderr = "FAILED test of %s\n\tat line 6 of <stdin>\n" % run_env.workpath('run'))

self.popen_python("""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
test = TestCmd.TestCmd(program = 'run', interpreter = 'python', description = 'xyzzy', workdir = '')
test.run()
test.fail_test(condition = (test.status == 0))
""" % self.orig_cwd, status = 1, stderr = "FAILED test of %s [xyzzy]\n\tat line 6 of <stdin>\n" % run_env.workpath('run'))

self.popen_python("""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
test = TestCmd.TestCmd(program = 'run', interpreter = 'python', workdir = '')
test.run()
Expand All @@ -895,7 +895,7 @@ def xxx():
""" % self.orig_cwd, status = 1, stderr = "printed on failure\nFAILED test of %s\n\tat line 8 of <stdin>\n" % run_env.workpath('run'))

self.popen_python("""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
def test1(self):
self.run()
Expand All @@ -906,7 +906,7 @@ def test2(self):
""" % self.orig_cwd, status = 1, stderr = "FAILED test of %s\n\tat line 6 of <stdin> (test1)\n\tfrom line 8 of <stdin> (test2)\n\tfrom line 9 of <stdin>\n" % run_env.workpath('run'))

self.popen_python("""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
def test1(self):
self.run()
Expand Down Expand Up @@ -1063,7 +1063,7 @@ def test_error(self):
# Now do the real test.
try:
script_input = """import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
assert TestCmd.match_re_dotall("abcde", r"a.*(e")
sys.exit(0)
Expand Down Expand Up @@ -1136,7 +1136,7 @@ def test_error(self):
# Now do the real test.
try:
script_input = """import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
assert TestCmd.match_re("abcde\\n", "a.*(e\\n")
sys.exit(0)
Expand Down Expand Up @@ -1346,29 +1346,29 @@ def test_no_result(self):
# Everything before this prepared our "source directory."
# Now do the real test.
self.popen_python("""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
TestCmd.no_result(condition = 1)
""" % self.orig_cwd, status = 2, stderr = "NO RESULT for test at line 4 of <stdin>\n")

self.popen_python("""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
test = TestCmd.TestCmd(program = 'run', interpreter = 'python', workdir = '')
test.run()
test.no_result(condition = (test.status == 0))
""" % self.orig_cwd, status = 2, stderr = "NO RESULT for test of %s\n\tat line 6 of <stdin>\n" % run_env.workpath('run'))

self.popen_python("""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
test = TestCmd.TestCmd(program = 'run', interpreter = 'python', description = 'xyzzy', workdir = '')
test.run()
test.no_result(condition = (test.status == 0))
""" % self.orig_cwd, status = 2, stderr = "NO RESULT for test of %s [xyzzy]\n\tat line 6 of <stdin>\n" % run_env.workpath('run'))

self.popen_python("""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
test = TestCmd.TestCmd(program = 'run', interpreter = 'python', workdir = '')
test.run()
Expand All @@ -1378,7 +1378,7 @@ def xxx():
""" % self.orig_cwd, status = 2, stderr = "printed on no result\nNO RESULT for test of %s\n\tat line 8 of <stdin>\n" % run_env.workpath('run'))

self.popen_python("""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
def test1(self):
self.run()
Expand All @@ -1389,7 +1389,7 @@ def test2(self):
""" % self.orig_cwd, status = 2, stderr = "NO RESULT for test of %s\n\tat line 6 of <stdin> (test1)\n\tfrom line 8 of <stdin> (test2)\n\tfrom line 9 of <stdin>\n" % run_env.workpath('run'))

self.popen_python("""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
def test1(self):
self.run()
Expand All @@ -1413,21 +1413,21 @@ def test_pass_test(self):
# Everything before this prepared our "source directory."
# Now do the real test.
self.popen_python("""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
TestCmd.pass_test(condition = 1)
""" % self.orig_cwd, stderr = "PASSED\n")

self.popen_python("""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
test = TestCmd.TestCmd(program = 'run', interpreter = 'python', workdir = '')
test.run()
test.pass_test(condition = (test.status == 0))
""" % self.orig_cwd, stderr = "PASSED\n")

self.popen_python("""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
test = TestCmd.TestCmd(program = 'run', interpreter = 'python', workdir = '')
test.run()
Expand Down Expand Up @@ -2051,7 +2051,7 @@ class set_diff_function_TestCase(TestCmdTestCase):
def test_set_diff_function(self):
"""Test set_diff_function()"""
self.popen_python(r"""import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
test = TestCmd.TestCmd()
test.diff("a\n", "a\n")
Expand All @@ -2064,7 +2064,7 @@ def test_set_diff_function_stdout(self):
"""Test set_diff_function(): stdout"""
self.popen_python("""\
import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
test = TestCmd.TestCmd()
print("diff:")
Expand Down Expand Up @@ -2093,7 +2093,7 @@ def test_set_diff_function_stderr(self):
"""Test set_diff_function(): stderr """
self.popen_python("""\
import sys
sys.path = ['%s'] + sys.path
sys.path = [r'%s'] + sys.path
import TestCmd
test = TestCmd.TestCmd()
print("diff:")
Expand Down
Loading