mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-09-09 07:51:59 -09:00
package/python-waitress: new package
The test runs the flask sample app through the waitress wsgi server instead of the flask development server. Signed-off-by: Marcus Hoffmann <buildroot@bubu1.eu> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
committed by
Thomas Petazzoni
parent
02c765af35
commit
1d4a61247d
34
support/testing/tests/package/test_python_waitress.py
Normal file
34
support/testing/tests/package/test_python_waitress.py
Normal file
@@ -0,0 +1,34 @@
|
||||
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
|
||||
else:
|
||||
self.assertTrue(False, "Timeout while waiting for waitress server")
|
||||
Reference in New Issue
Block a user