mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-13 10:22:55 +01:00
Fix Python test scripts for Python 3 and Windows
This commit is contained in:
parent
59a01652ab
commit
01aee4a0dc
@ -34,7 +34,7 @@ def compareOutputs( expected, actual, message ):
|
|||||||
|
|
||||||
def safeReadFile( path ):
|
def safeReadFile( path ):
|
||||||
try:
|
try:
|
||||||
return file( path, 'rt' ).read()
|
return open( path, 'rt', encoding = 'utf-8' ).read()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
return '<File "%s" is missing: %s>' % (path,e)
|
return '<File "%s" is missing: %s>' % (path,e)
|
||||||
|
|
||||||
@ -77,13 +77,13 @@ def runAllTests( jsontest_executable_path, input_dir = None,
|
|||||||
base_path = os.path.splitext(input_path)[0]
|
base_path = os.path.splitext(input_path)[0]
|
||||||
actual_output = safeReadFile( base_path + '.actual' )
|
actual_output = safeReadFile( base_path + '.actual' )
|
||||||
actual_rewrite_output = safeReadFile( base_path + '.actual-rewrite' )
|
actual_rewrite_output = safeReadFile( base_path + '.actual-rewrite' )
|
||||||
file(base_path + '.process-output','wt').write( process_output )
|
open(base_path + '.process-output', 'wt', encoding = 'utf-8').write( process_output )
|
||||||
if status:
|
if status:
|
||||||
print('parsing failed')
|
print('parsing failed')
|
||||||
failed_tests.append( (input_path, 'Parsing failed:\n' + process_output) )
|
failed_tests.append( (input_path, 'Parsing failed:\n' + process_output) )
|
||||||
else:
|
else:
|
||||||
expected_output_path = os.path.splitext(input_path)[0] + '.expected'
|
expected_output_path = os.path.splitext(input_path)[0] + '.expected'
|
||||||
expected_output = file( expected_output_path, 'rt' ).read()
|
expected_output = open( expected_output_path, 'rt', encoding = 'utf-8' ).read()
|
||||||
detail = ( compareOutputs( expected_output, actual_output, 'input' )
|
detail = ( compareOutputs( expected_output, actual_output, 'input' )
|
||||||
or compareOutputs( expected_output, actual_rewrite_output, 'rewrite' ) )
|
or compareOutputs( expected_output, actual_rewrite_output, 'rewrite' ) )
|
||||||
if detail:
|
if detail:
|
||||||
|
@ -31,7 +31,7 @@ def runAllTests( exe_path, use_valgrind=False ):
|
|||||||
if not status:
|
if not status:
|
||||||
print("Failed to obtain unit tests list:\n" + test_names, file=sys.stderr)
|
print("Failed to obtain unit tests list:\n" + test_names, file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
test_names = [name.strip() for name in test_names.strip().split('\n')]
|
test_names = [name.strip() for name in test_names.decode('utf-8').strip().split('\n')]
|
||||||
failures = []
|
failures = []
|
||||||
for name in test_names:
|
for name in test_names:
|
||||||
print('TESTING %s:' % name, end=' ')
|
print('TESTING %s:' % name, end=' ')
|
||||||
|
Loading…
Reference in New Issue
Block a user