mirror of
https://github.com/HorlogeSkynet/archey4
synced 2025-05-05 00:00:11 +02:00
Compare commits
2 Commits
4d084b8474
...
e893beb1e8
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e893beb1e8 | ||
![]() |
7fe149b825 |
archey
@ -13,7 +13,7 @@ class Singleton(AbstractBaseMetaClass):
|
||||
... whereas it is effectively loaded only once.
|
||||
You cannot instantiate this meta-class directly.
|
||||
"""
|
||||
_instances = {} # type: Dict[Type['Singleton'], object]
|
||||
_instances = {} # type: Dict[Type['Singleton'], type]
|
||||
|
||||
def __call__(cls, *args, **kwargs):
|
||||
if cls not in cls._instances:
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
from copy import deepcopy
|
||||
from functools import wraps
|
||||
from typing import Callable
|
||||
|
||||
import unittest
|
||||
from unittest.mock import MagicMock, patch
|
||||
@ -17,7 +18,7 @@ class HelperMethods:
|
||||
We kindly borrow `update_recursive` class method from `Configuration` to DRY its implementation.
|
||||
"""
|
||||
@staticmethod
|
||||
def entry_mock(entry, options=None, configuration=None):
|
||||
def entry_mock(entry, options: dict = None, configuration: dict = None) -> MagicMock:
|
||||
"""
|
||||
Creates a placeholder "instance" of the entry class passed, with a clean default
|
||||
`_default_strings` which is optionally updated by `configuration`.
|
||||
@ -49,7 +50,11 @@ class HelperMethods:
|
||||
return instance_mock
|
||||
|
||||
@staticmethod
|
||||
def patch_clean_configuration(method_definition=None, *, configuration=None):
|
||||
def patch_clean_configuration(
|
||||
method_definition: Callable = None,
|
||||
*,
|
||||
configuration: dict = None
|
||||
) -> Callable:
|
||||
"""
|
||||
Decorator for an entry test definition, which sets the entry's `_default_strings` attribute
|
||||
to the Archey defaults, optionally updated with `configuration`.
|
||||
@ -60,7 +65,7 @@ class HelperMethods:
|
||||
# Then, let's merge in `configuration` recursively.
|
||||
Configuration.update_recursive(entry_configuration, (configuration or {}))
|
||||
|
||||
def decorator_patch_clean_configuration(method):
|
||||
def decorator_patch_clean_configuration(method: Callable) -> Callable:
|
||||
@wraps(method)
|
||||
def wrapper_patch_clean_configuration(*args, **kwargs):
|
||||
with patch('archey.entry.Configuration', autospec=True) as config_instance_mock:
|
||||
|
Loading…
x
Reference in New Issue
Block a user