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 time.sleep(15) 25 26 cmd = "wget -q -O - http://127.0.0.1:5000/" 27 output, exit_code = self.emulator.run(cmd, timeout=self.timeout) 28 self.assertEqual(exit_code, 0) 29 self.assertEqual(output[0], "Hello, World!") 30