Skip to content

Commit 0fd95cb

Browse files
author
Philip Guo
committed
updated regression test suite and added new test
1 parent f84e907 commit 0fd95cb

5 files changed

Lines changed: 49 additions & 8 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"code": "# test case of Python 3 function annotations inspired by David G. Kay\ndef remove_by_name(L: 'list of Restaurant', name: str) -> 'list of Restaurant':\n \"\"\" Given name, remove all Restaurants with that name from collection.\n \"\"\"\n result = []\n for r in L:\n if r.name != name:\n result.append(r)\n return result\n",
3+
"trace": [
4+
{
5+
"exception_msg": "SyntaxError: invalid syntax (<string>, line 2)",
6+
"line": 2,
7+
"event": "uncaught_exception",
8+
"offset": 21
9+
}
10+
]
11+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"code": "# test case of Python 3 function annotations inspired by David G. Kay\ndef remove_by_name(L: 'list of Restaurant', name: str) -> 'list of Restaurant':\n \"\"\" Given name, remove all Restaurants with that name from collection.\n \"\"\"\n result = []\n for r in L:\n if r.name != name:\n result.append(r)\n return result\n",
3+
"trace": [
4+
{
5+
"ordered_globals": [],
6+
"stdout": "",
7+
"func_name": "<module>",
8+
"stack_to_render": [],
9+
"globals": {},
10+
"heap": {},
11+
"line": 2,
12+
"event": "step_line"
13+
},
14+
{
15+
"exception_msg": "ValueError: Function has keyword-only arguments or annotations, use getfullargspec() API which can support them",
16+
"event": "uncaught_exception"
17+
}
18+
]
19+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# test case of Python 3 function annotations inspired by David G. Kay
2+
def remove_by_name(L: 'list of Restaurant', name: str) -> 'list of Restaurant':
3+
""" Given name, remove all Restaurants with that name from collection.
4+
"""
5+
result = []
6+
for r in L:
7+
if r.name != name:
8+
result.append(r)
9+
return result

‎v3/tests/golden_test.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ def execute(input_filename):
2424
print '(has stderr)'
2525
# print ' stderr {'
2626
# print stderr, '}'
27+
else:
28+
print
2729

2830
# capture stdout into outfile, filtering out machine-specific addresses
2931
outfile = base + OUTPUT_FILE_EXTENSION
@@ -84,7 +86,7 @@ def diff_test_output(test_name):
8486

8587

8688
def run_test(input_filename, clobber_golden=False):
87-
print 'Testing', input_filename
89+
print 'Testing', input_filename,
8890

8991
(base, ext) = os.path.splitext(input_filename)
9092
assert ext == INPUT_FILE_EXTENSION
@@ -131,18 +133,18 @@ def diff_all_test_outputs():
131133
parser.add_option("--diffall", action="store_true", dest="diff_all",
132134
help="Diff against golden file for all tests")
133135
parser.add_option("--py3", action="store_true", dest="py3",
134-
help="Run Python 3 tests (rather than Python 2)")
136+
help="Run tests using Python 3.2 (rather than Python 2.7)")
135137
(options, args) = parser.parse_args()
136138

137139

138140
INPUT_FILE_EXTENSION = '.txt' # input test files are .txt, NOT .py
139141

140142
if options.py3:
141-
PROGRAM = ['python3', '../generate_json_trace.py']
143+
PROGRAM = ['python3.2', '../generate_json_trace.py']
142144
OUTPUT_FILE_EXTENSION = '.out_py3'
143145
GOLDEN_FILE_EXTENSION = '.golden_py3'
144146
else:
145-
PROGRAM = ['python2', '../generate_json_trace.py']
147+
PROGRAM = ['python2.7', '../generate_json_trace.py']
146148
OUTPUT_FILE_EXTENSION = '.out'
147149
GOLDEN_FILE_EXTENSION = '.golden'
148150

‎v3/tests/run-all-tests.sh‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/sh
2-
echo 'Python 2 test'
3-
echo '============='
2+
echo 'Python 2.7 test'
3+
echo '==============='
44
python golden_test.py --all
55
echo
6-
echo 'Python 3 test'
7-
echo '============='
6+
echo 'Python 3.2 test'
7+
echo '==============='
88
python golden_test.py --all --py3

0 commit comments

Comments
 (0)