File tree Expand file tree Collapse file tree 2 files changed +18
-10
lines changed Expand file tree Collapse file tree 2 files changed +18
-10
lines changed Original file line number Diff line number Diff line change
1
+ import asyncio
2
+ import unittest
3
+ from typing import TypeVar , Awaitable
4
+
5
+ T = TypeVar ('T' )
6
+
7
+
8
+ class AsyncTestCase (unittest .TestCase ):
9
+ def await_ (self , awaitable : Awaitable [T ]) -> T :
10
+ return self .loop .run_until_complete (awaitable )
11
+
12
+ def setUp (self ) -> None :
13
+ super ().setUp ()
14
+
15
+ self .loop = asyncio .get_event_loop ()
Original file line number Diff line number Diff line change 1
1
import io
2
2
import json
3
- import asyncio
4
3
import zipfile
5
4
import datetime
6
5
import tempfile
7
- import unittest
8
- from typing import IO , TypeVar , Awaitable
6
+ from typing import IO
9
7
from unittest import mock
10
8
11
9
import alembic # type: ignore[import]
10
+ import test_utils
12
11
from sqlalchemy import create_engine
13
12
from alembic .config import Config # type: ignore[import]
14
13
from starlette .config import environ
15
14
from starlette .testclient import TestClient
16
15
from code_submitter .tables import Archive , ChoiceHistory
17
16
18
- T = TypeVar ('T' )
19
-
20
17
DATABASE_FILE : IO [bytes ]
21
18
22
19
@@ -39,10 +36,7 @@ def setUpModule() -> None:
39
36
alembic .command .upgrade (Config ('alembic.ini' ), 'head' )
40
37
41
38
42
- class AppTests (unittest .TestCase ):
43
- def await_ (self , awaitable : Awaitable [T ]) -> T :
44
- return self .loop .run_until_complete (awaitable )
45
-
39
+ class AppTests (test_utils .AsyncTestCase ):
46
40
def setUp (self ) -> None :
47
41
super ().setUp ()
48
42
@@ -54,7 +48,6 @@ def setUp(self) -> None:
54
48
self .session .auth = ('test_user' , 'test_pass' )
55
49
self .url_path_for = app .url_path_for
56
50
self .database = database
57
- self .loop = asyncio .get_event_loop ()
58
51
59
52
def tearDown (self ) -> None :
60
53
self .session .__exit__ (None , None , None )
You can’t perform that action at this time.
0 commit comments