conftest.py 1005 B

12345678910111213141516171819202122232425262728293031323334
  1. # This file is dual licensed under the terms of the Apache License, Version
  2. # 2.0, and the BSD License. See the LICENSE file in the root of this repository
  3. # for complete details.
  4. from __future__ import absolute_import, division, print_function
  5. import pytest
  6. from cryptography.hazmat.backends.openssl import backend as openssl_backend
  7. from .utils import check_backend_support
  8. def pytest_report_header(config):
  9. return "OpenSSL: {0}".format(openssl_backend.openssl_version_text())
  10. @pytest.fixture()
  11. def backend(request):
  12. required_interfaces = [
  13. mark.kwargs["interface"]
  14. for mark in request.node.get_marker("requires_backend_interface")
  15. ]
  16. if not all(
  17. isinstance(openssl_backend, iface) for iface in required_interfaces
  18. ):
  19. pytest.skip(
  20. "OpenSSL doesn't implement required interfaces: {0}".format(
  21. required_interfaces
  22. )
  23. )
  24. check_backend_support(openssl_backend, request)
  25. return openssl_backend