Files
rpi-buildroot/support/testing/tests/package/test_python_waitress.py
Thomas Petazzoni 824c660c75 support/testing/tests/package/test_python_waitress: rework assertion
Like Yann E. Morin did for
support/testing/tests/package/test_python_django.py, adjust the logic
to avoid the weird "self.assertTrue(False, ...)" construct, and
instead test exit_code after the loop.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2025-02-05 11:19:27 +01:00

34 lines
1.1 KiB
Python

import time
from tests.package.test_python import TestPythonPackageBase
class TestPythonWaitress(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_FLASK=y
BR2_PACKAGE_PYTHON_WAITRESS=y
"""
sample_scripts = ["tests/package/sample_python_flask.py"]
def test_run(self):
self.login()
self.check_sample_scripts_exist()
cmd = self.interpreter + " -m waitress sample_python_flask:app > /dev/null 2>&1 &"
# give some time to setup the server
_, exit = self.emulator.run(cmd, timeout=self.timeout)
# Give enough time for the uvicorn server to start up
for attempt in range(30):
time.sleep(1)
cmd = "wget -q -O - http://127.0.0.1:8080/"
output, exit_code = self.emulator.run(cmd, timeout=self.timeout)
if exit_code == 0:
self.assertEqual(output[0], 'Hello, World!')
break
self.assertEqual(exit_code, 0, "Timeout while waiting for django server")