Skip to content

Instantly share code, notes, and snippets.

@trszdev
Created April 27, 2019 21:36
Show Gist options
  • Save trszdev/1ff56ae410168bb2a66474dd988f75e2 to your computer and use it in GitHub Desktop.
Save trszdev/1ff56ae410168bb2a66474dd988f75e2 to your computer and use it in GitHub Desktop.
python competitive programming template for pytest
from sys import *
def main(cin, cout):
a, b = map(int, cin.readline().split())
cout.write(str(a + b))
def get_main_output(input_str):
from io import StringIO
cin = StringIO(input_str)
cout = StringIO()
main(cin, cout)
return cout.getvalue()
def test_example():
out = get_main_output('1 -2')
assert out == '-1'
if __name__ == '__main__':
main(stdin, stdout)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment