mirror of
https://github.com/lilydjwg/nvchecker.git
synced 2025-03-10 06:14:02 +00:00
handle deprecated warning, reindent conftest.py
This commit is contained in:
parent
903b414183
commit
26eaef92aa
2 changed files with 35 additions and 35 deletions
|
@ -20,7 +20,7 @@ for repo in _ANDROID_REPO_MANIFESTS.keys():
|
||||||
_repo_manifests_locks[repo] = Lock()
|
_repo_manifests_locks[repo] = Lock()
|
||||||
|
|
||||||
async def _get_repo_manifest(repo):
|
async def _get_repo_manifest(repo):
|
||||||
with (await _repo_manifests_locks[repo]):
|
async with _repo_manifests_locks[repo]:
|
||||||
if repo in _repo_manifests_cache:
|
if repo in _repo_manifests_cache:
|
||||||
return _repo_manifests_cache[repo]
|
return _repo_manifests_cache[repo]
|
||||||
|
|
||||||
|
|
|
@ -8,58 +8,58 @@ from nvchecker.get_version import get_version as _get_version
|
||||||
from nvchecker.core import Source
|
from nvchecker.core import Source
|
||||||
|
|
||||||
class TestSource(Source):
|
class TestSource(Source):
|
||||||
def __init__(self, future, *args, **kwargs):
|
def __init__(self, future, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self._future = future
|
self._future = future
|
||||||
|
|
||||||
def on_update(self, name, version, oldver):
|
def on_update(self, name, version, oldver):
|
||||||
self._future.set_result(version)
|
self._future.set_result(version)
|
||||||
|
|
||||||
def on_no_result(self, name):
|
def on_no_result(self, name):
|
||||||
self._future.set_result(None)
|
self._future.set_result(None)
|
||||||
|
|
||||||
def on_exception(self, name, exc):
|
def on_exception(self, name, exc):
|
||||||
self._future.set_exception(exc)
|
self._future.set_exception(exc)
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
async def run_source():
|
async def run_source():
|
||||||
async def __call__(conf):
|
async def __call__(conf):
|
||||||
future = asyncio.Future()
|
future = asyncio.Future()
|
||||||
file = io.StringIO(conf)
|
file = io.StringIO(conf)
|
||||||
file.name = '<StringIO>'
|
file.name = '<StringIO>'
|
||||||
|
|
||||||
s = TestSource(future, file)
|
s = TestSource(future, file)
|
||||||
await s.check()
|
await s.check()
|
||||||
return await future
|
return await future
|
||||||
|
|
||||||
return __call__
|
return __call__
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
async def get_version():
|
async def get_version():
|
||||||
async def __call__(name, config):
|
async def __call__(name, config):
|
||||||
|
|
||||||
if isinstance(config, dict):
|
if isinstance(config, dict):
|
||||||
_config = configparser.ConfigParser(dict_type=dict, allow_no_value=True)
|
_config = configparser.ConfigParser(dict_type=dict, allow_no_value=True)
|
||||||
_config.read_dict({name: config})
|
_config.read_dict({name: config})
|
||||||
config = _config[name]
|
config = _config[name]
|
||||||
|
|
||||||
return await _get_version(name, config)
|
return await _get_version(name, config)
|
||||||
|
|
||||||
return __call__
|
return __call__
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def event_loop(request):
|
def event_loop(request):
|
||||||
"""Override pytest-asyncio's event_loop fixture,
|
"""Override pytest-asyncio's event_loop fixture,
|
||||||
Don't create an instance of the default event loop for each test case.
|
Don't create an instance of the default event loop for each test case.
|
||||||
"""
|
"""
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
yield loop
|
yield loop
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def raise_on_logger_msg():
|
def raise_on_logger_msg():
|
||||||
def proc(logger, method_name, event_dict):
|
def proc(logger, method_name, event_dict):
|
||||||
if method_name in ('warn', 'error'):
|
if method_name in ('warn', 'error'):
|
||||||
raise RuntimeError(event_dict['event'])
|
raise RuntimeError(event_dict['event'])
|
||||||
return event_dict['event']
|
return event_dict['event']
|
||||||
|
|
||||||
structlog.configure([proc])
|
structlog.configure([proc])
|
||||||
|
|
Loading…
Add table
Reference in a new issue