Skip to content

Commit

Permalink
Merge pull request #5 from brennv/python3
Browse files Browse the repository at this point in the history
Add Python3
  • Loading branch information
kaushik94 authored Feb 9, 2018
2 parents 440756a + 5e2d0fb commit 8c98e5d
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 33 deletions.
44 changes: 22 additions & 22 deletions Alex/alex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand All @@ -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())

Expand All @@ -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):
Expand All @@ -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__':
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ='[email protected]' ,
author='Kaushik Varanasi',
author_email ='[email protected]',
license='MIT',
keywords=['Python' ,'Competetive Programming' ,'Test cases' ,'command line', 'cli'],
url='http://github.com/kaushik94/alex',
Expand All @@ -19,6 +19,7 @@
},
install_requires=[
'docopt>=0.6.1',
'future'
],
entry_points={
'console_scripts': [
Expand Down
5 changes: 4 additions & 1 deletion tests/test.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from builtins import input


def solveMeFirst(a,b):
return a+b


num1 = input()
num2 = input()
res = solveMeFirst(num1,num2)
print res
print(res)

"""I
2
Expand Down
2 changes: 1 addition & 1 deletion tests/test_input.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
print "helloworld"
print("helloworld")
2 changes: 1 addition & 1 deletion tests/test_input1.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
print "helloworld"
print("helloworld")
9 changes: 6 additions & 3 deletions tests/test_input2.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 6 additions & 3 deletions tests/test_input3.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 8c98e5d

Please sign in to comment.