Skip to content

Commit 570bdb2

Browse files
committed
Fix async in tests
1 parent dd28ba2 commit 570bdb2

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

cloudbot/util/mapping.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
import weakref
22
from collections import defaultdict
3-
from typing import (
4-
TYPE_CHECKING,
5-
Generic,
6-
Optional,
7-
Protocol,
8-
TypeVar,
9-
Union,
10-
cast,
11-
)
3+
from typing import TYPE_CHECKING, Generic, Optional, TypeVar, Union, cast
124

135
__all__ = (
146
"KeyFoldDict",
@@ -24,6 +16,7 @@
2416

2517

2618
if TYPE_CHECKING:
19+
from typing import Protocol
2720

2821
class MapBase(Protocol[K_contra, V]):
2922
def __getitem__(self, item: K_contra) -> V:

tests/core_tests/test_main.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
import logging
22
from unittest.mock import patch
33

4-
from cloudbot.__main__ import main
4+
import pytest
55

6+
from cloudbot.__main__ import async_main
7+
8+
9+
@pytest.mark.asyncio
10+
async def test_main():
11+
async def run():
12+
return False
613

7-
def test_main():
814
with patch("cloudbot.__main__.CloudBot") as mocked:
9-
mocked().run.return_value = False
10-
main()
15+
mocked().run = run
16+
await async_main()
1117
assert logging._srcfile is None
1218
assert not logging.logThreads
1319
assert not logging.logProcesses

0 commit comments

Comments
 (0)