diff --git a/qbay_test/frontend/__init__.py b/qbay_test/frontend/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/qbay_test/frontend/test_login/__init__.py b/qbay_test/frontend/test_login/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/qbay_test/frontend/test_login/test_login.in b/qbay_test/frontend/test_login/test_login.in new file mode 100644 index 0000000..bb05169 --- /dev/null +++ b/qbay_test/frontend/test_login/test_login.in @@ -0,0 +1,3 @@ +1 +test0@test.com +123456 diff --git a/qbay_test/frontend/test_login/test_login.out b/qbay_test/frontend/test_login/test_login.out new file mode 100644 index 0000000..eb14d50 --- /dev/null +++ b/qbay_test/frontend/test_login/test_login.out @@ -0,0 +1 @@ +Welcome. Please type 1 to login. Or type 2 register. Or type 3 to exitPlease input emailPlease input password:welcome u0 \ No newline at end of file diff --git a/qbay_test/frontend/test_login/test_login.py b/qbay_test/frontend/test_login/test_login.py new file mode 100644 index 0000000..996ad8f --- /dev/null +++ b/qbay_test/frontend/test_login/test_login.py @@ -0,0 +1,30 @@ +from os import popen +from pathlib import Path +import subprocess + +# get expected input/output file +current_folder = Path(__file__).parent + + +# read expected in/out +expected_in = open(current_folder.joinpath( + 'test_login.in')) +expected_out = open(current_folder.joinpath( + 'test_login.out')).read() + +print(expected_out) + + +def test_login(): + """capsys -- object created by pytest to + capture stdout and stderr""" + + # pip the input + output = subprocess.run( + ['python', '-m', 'qbay'], + stdin=expected_in, + capture_output=True, + ).stdout.decode() + + print('outputs', output) + assert output.strip() == expected_out.strip()