test_python_cryptography.py 873 B

12345678910111213141516171819202122232425262728293031
  1. import os
  2. from tests.package.test_python import TestPythonBase
  3. class TestPythonCryptography(TestPythonBase):
  4. def fernet_test(self, timeout=-1):
  5. cmd = self.interpreter + " -c 'from cryptography.fernet import Fernet;"
  6. cmd += "key = Fernet.generate_key();"
  7. cmd += "f = Fernet(key)'"
  8. _, exit_code = self.emulator.run(cmd, timeout)
  9. self.assertEqual(exit_code, 0)
  10. class TestPythonPy2Cryptography(TestPythonCryptography):
  11. config = TestPythonBase.config + \
  12. """
  13. BR2_PACKAGE_PYTHON=y
  14. BR2_PACKAGE_PYTHON_CRYPTOGRAPHY=y
  15. """
  16. def test_run(self):
  17. self.login()
  18. self.fernet_test(40)
  19. class TestPythonPy3Cryptography(TestPythonCryptography):
  20. config = TestPythonBase.config + \
  21. """
  22. BR2_PACKAGE_PYTHON3=y
  23. BR2_PACKAGE_PYTHON_CRYPTOGRAPHY=y
  24. """
  25. def test_run(self):
  26. self.login()
  27. self.fernet_test(40)