1from tests.package.test_python import TestPythonPackageBase 2import os 3import time 4 5 6class TestPythonPy3Flask(TestPythonPackageBase): 7 __test__ = True 8 config = TestPythonPackageBase.config + \ 9 """ 10 BR2_PACKAGE_PYTHON3=y 11 BR2_PACKAGE_PYTHON_FLASK=y 12 """ 13 sample_scripts = ["tests/package/sample_python_flask.py"] 14 timeout = 60 15 16 def test_run(self): 17 self.login() 18 self.check_sample_scripts_exist() 19 cmd = "FLASK_APP=%s %s -m flask run > /dev/null 2>&1 &" % (os.path.basename(self.sample_scripts[0]), 20 self.interpreter) 21 _, exit_code = self.emulator.run(cmd, timeout=self.timeout) 22 23 # Give enough time for the flask server to start up 24 for attempt in range(30): 25 time.sleep(1) 26 27 cmd = "wget -q -O - http://127.0.0.1:5000/" 28 output, exit_code = self.emulator.run(cmd, timeout=self.timeout) 29 if exit_code == 0: 30 self.assertEqual(output[0], 'Hello, World!') 31 break 32 else: 33 self.assertTrue(False, "Timeout while waiting for flask server") 34