test_python_flask.py 1019 B

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