mirror of
https://github.com/saymrwulf/cryptography.git
synced 2026-05-15 20:40:20 +00:00
* _ModuleWithDeprecations should inherit from types.ModuleType (#6267) Update utils.py * fix typos reported by black * flake8 fix * Test should fail when int_from_bytes will be removed. Because this test would become pointless then.
This commit is contained in:
parent
7b5634911c
commit
bacf23f3ed
2 changed files with 15 additions and 1 deletions
|
|
@ -7,6 +7,7 @@ import abc
|
|||
import enum
|
||||
import inspect
|
||||
import sys
|
||||
import types
|
||||
import typing
|
||||
import warnings
|
||||
|
||||
|
|
@ -113,8 +114,9 @@ class _DeprecatedValue(object):
|
|||
self.warning_class = warning_class
|
||||
|
||||
|
||||
class _ModuleWithDeprecations(object):
|
||||
class _ModuleWithDeprecations(types.ModuleType):
|
||||
def __init__(self, module):
|
||||
super().__init__(module.__name__)
|
||||
self.__dict__["_module"] = module
|
||||
|
||||
def __getattr__(self, attr):
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
|
||||
import binascii
|
||||
import inspect
|
||||
import os
|
||||
import textwrap
|
||||
|
||||
|
|
@ -12,6 +13,7 @@ import pretend
|
|||
import pytest
|
||||
|
||||
import cryptography
|
||||
import cryptography.utils
|
||||
from cryptography.exceptions import UnsupportedAlgorithm, _Reasons
|
||||
|
||||
import cryptography_vectors
|
||||
|
|
@ -4444,3 +4446,13 @@ def test_raises_unsupported_algorithm():
|
|||
"An error.", _Reasons.BACKEND_MISSING_INTERFACE
|
||||
)
|
||||
assert exc_info.type is UnsupportedAlgorithm
|
||||
|
||||
|
||||
def test_inspect_deprecated_module():
|
||||
# Check if inspection is supported by _ModuleWithDeprecations.
|
||||
assert isinstance(
|
||||
cryptography.utils, cryptography.utils._ModuleWithDeprecations
|
||||
)
|
||||
source_file = inspect.getsourcefile(cryptography.utils)
|
||||
assert isinstance(source_file, str)
|
||||
assert source_file.endswith("utils.py")
|
||||
|
|
|
|||
Loading…
Reference in a new issue