File: conftest.py

package info (click to toggle)
pyopenssl 26.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,476 kB
  • sloc: python: 8,722; makefile: 116
file content (33 lines) | stat: -rw-r--r-- 749 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Copyright (c) The pyOpenSSL developers
# See LICENSE for details.

import pathlib
from tempfile import mktemp

import pytest

from OpenSSL.SSL import OPENSSL_VERSION, SSLeay_version

is_awslc = b"AWS-LC" in SSLeay_version(OPENSSL_VERSION)


def pytest_report_header(config: pytest.Config) -> str:
    import cryptography

    import OpenSSL.SSL

    return (
        f"OpenSSL: "
        f"{OpenSSL.SSL.SSLeay_version(OpenSSL.SSL.SSLEAY_VERSION)!r}\n"
        f"cryptography: {cryptography.__version__}"
    )


@pytest.fixture
def tmpfile(tmp_path: pathlib.Path) -> bytes:
    """
    Return UTF-8-encoded bytes of a path to a tmp file.

    The file will be cleaned up after the test run.
    """
    return mktemp(dir=tmp_path).encode("utf-8")