diff --git a/Alex/alex.py b/Alex/alex.py index 286d0e6..1a69cb4 100644 --- a/Alex/alex.py +++ b/Alex/alex.py @@ -7,7 +7,7 @@ FILE input file """ - +from __future__ import print_function from docopt import docopt from subprocess import Popen, PIPE, STDOUT, call import re @@ -47,8 +47,8 @@ def _test_python_input_output(filename, inputs, outputs): @timer def do_it(filename, one): - p = Popen(['python', filename], stdout=PIPE, stdin=PIPE, stderr=STDOUT) - grep_stdout = p.communicate(input=one)[0] + p = Popen(['python', filename], stdout=PIPE, stdin=PIPE, stderr=STDOUT) + grep_stdout = p.communicate(input=one.encode())[0] # print(grep_stdout.decode()) return grep_stdout.decode() @@ -60,7 +60,7 @@ def _test_python_input(filename, inputs): @timer def _test_python_normal(filename): - p = Popen(['python', filename], stdout=PIPE, stdin=PIPE, stderr=STDOUT) + p = Popen(['python', filename], stdout=PIPE, stdin=PIPE, stderr=STDOUT) grep_stdout = p.communicate()[0] print(grep_stdout.decode()) @@ -76,10 +76,10 @@ def _run_python_tests(arguments): if inputs: return _test_python_input(arguments['FILE_NAME'], inputs) else: - print 'No test cases were provided so running as is' - print - print 'YOUR OUTPUT' - print '===========' + print('No test cases were provided so running as is') + print() + print('YOUR OUTPUT') + print('===========') _test_python_normal(arguments['FILE_NAME']) def _run_tests(arguments): @@ -95,29 +95,29 @@ def pretty_print(to_print, times): return '' if len(to_print) is 3: bool_res, results, expected = to_print - print "YOUR OUTPUT" - print '===========' + print("YOUR OUTPUT") + print('===========') for each in results: - print each - print "EXPECTED OUTPUT" - print '===============' + print(each) + print("EXPECTED OUTPUT") + print('===============') for each in expected: - print each - print "PASS/FAIL (of %d testcases)"%len(results) - print '=========' + print(each) + print("PASS/FAIL (of %d testcases)"%len(results)) + print('=========') for index, each in enumerate(bool_res): - print 'TESTCASE %d'%(index+1), status(each), times[index], 'seconds' + print('TESTCASE %d'%(index+1), status(each), times[index], 'seconds') if len(to_print) is 1: - print "YOUR OUTPUT" - print '===========' - print to_print[0] + print("YOUR OUTPUT") + print('===========') + print(to_print[0]) def main(): arguments = docopt(__doc__) if len(arguments) is not 1: raise ValueError('Expected 1 argument, %d given'%len(arguments)) - print 'Alex is working on ', arguments['FILE_NAME'] - print + print('Alex is working on ', arguments['FILE_NAME']) + print() pretty_print(_run_tests(arguments), time_log) if __name__ == '__main__': diff --git a/setup.py b/setup.py index a88bb79..f97839c 100644 --- a/setup.py +++ b/setup.py @@ -8,8 +8,8 @@ version=version, description='Alex executes your python scripts with test cases embedded', long_description=open('README.rst').read(), - author='Kaushik Varanasi, ', - author_email ='kaushik.varanasi1@gmail.com' , + author='Kaushik Varanasi', + author_email ='kaushik.varanasi1@gmail.com', license='MIT', keywords=['Python' ,'Competetive Programming' ,'Test cases' ,'command line', 'cli'], url='http://github.com/kaushik94/alex', @@ -19,6 +19,7 @@ }, install_requires=[ 'docopt>=0.6.1', + 'future' ], entry_points={ 'console_scripts': [ diff --git a/tests/test.py b/tests/test.py index 6371b1a..3de6288 100644 --- a/tests/test.py +++ b/tests/test.py @@ -1,3 +1,6 @@ +from builtins import input + + def solveMeFirst(a,b): return a+b @@ -5,7 +8,7 @@ def solveMeFirst(a,b): num1 = input() num2 = input() res = solveMeFirst(num1,num2) -print res +print(res) """I 2 diff --git a/tests/test_input.py b/tests/test_input.py index d730796..590e2c0 100644 --- a/tests/test_input.py +++ b/tests/test_input.py @@ -1 +1 @@ -print "helloworld" +print("helloworld") diff --git a/tests/test_input1.py b/tests/test_input1.py index d730796..590e2c0 100644 --- a/tests/test_input1.py +++ b/tests/test_input1.py @@ -1 +1 @@ -print "helloworld" +print("helloworld") diff --git a/tests/test_input2.py b/tests/test_input2.py index 6c5489a..e573cd2 100644 --- a/tests/test_input2.py +++ b/tests/test_input2.py @@ -1,13 +1,16 @@ +from builtins import input + + def solveMeSecond(a,b): return a+b -n = int(raw_input()) +n = int(input()) for i in range(0,n): - a, b = raw_input().split() + a, b = input().split() a,b = int(a),int(b) res = solveMeSecond(a,b) - print res + print(res) """I 2 diff --git a/tests/test_input3.py b/tests/test_input3.py index 4199930..ceea73b 100644 --- a/tests/test_input3.py +++ b/tests/test_input3.py @@ -1,13 +1,16 @@ +from builtins import input + + def solveMeSecond(a,b): return a+b -n = int(raw_input()) +n = int(input()) for i in range(0,n): - a, b = raw_input().split() + a, b = input().split() a,b = int(a),int(b) res = solveMeSecond(a,b) - print res + print(res) """I 2