1
1
import asyncio
2
+ import contextvars
2
3
import decimal
3
4
import random
4
- import sys
5
- import unittest
6
5
import weakref
7
6
8
7
from uvloop import _testbase as tb
9
8
10
9
11
- PY37 = sys .version_info >= (3 , 7 , 0 )
12
-
13
-
14
10
class _ContextBaseTests :
15
11
16
- @unittest .skipUnless (PY37 , 'requires Python 3.7' )
17
12
def test_task_decimal_context (self ):
18
13
async def fractions (t , precision , x , y ):
19
14
with decimal .localcontext () as ctx :
@@ -37,9 +32,7 @@ async def main():
37
32
self .assertEqual (str (r2 [0 ]), '0.333333' )
38
33
self .assertEqual (str (r2 [1 ]), '0.111111' )
39
34
40
- @unittest .skipUnless (PY37 , 'requires Python 3.7' )
41
35
def test_task_context_1 (self ):
42
- import contextvars
43
36
cvar = contextvars .ContextVar ('cvar' , default = 'nope' )
44
37
45
38
async def sub ():
@@ -58,9 +51,7 @@ async def main():
58
51
task = self .loop .create_task (main ())
59
52
self .loop .run_until_complete (task )
60
53
61
- @unittest .skipUnless (PY37 , 'requires Python 3.7' )
62
54
def test_task_context_2 (self ):
63
- import contextvars
64
55
cvar = contextvars .ContextVar ('cvar' , default = 'nope' )
65
56
66
57
async def main ():
@@ -90,9 +81,7 @@ def fut_on_done(fut):
90
81
91
82
self .assertEqual (cvar .get (), 'nope' )
92
83
93
- @unittest .skipUnless (PY37 , 'requires Python 3.7' )
94
84
def test_task_context_3 (self ):
95
- import contextvars
96
85
cvar = contextvars .ContextVar ('cvar' , default = - 1 )
97
86
98
87
# Run 100 Tasks in parallel, each modifying cvar.
@@ -115,9 +104,7 @@ async def main():
115
104
116
105
self .assertEqual (cvar .get (), - 1 )
117
106
118
- @unittest .skipUnless (PY37 , 'requires Python 3.7' )
119
107
def test_task_context_4 (self ):
120
- import contextvars
121
108
cvar = contextvars .ContextVar ('cvar' , default = 'nope' )
122
109
123
110
class TrackMe :
@@ -141,23 +128,7 @@ async def main():
141
128
142
129
143
130
class Test_UV_Context (_ContextBaseTests , tb .UVTestCase ):
144
-
145
- @unittest .skipIf (PY37 , 'requires Python <3.6' )
146
- def test_context_arg (self ):
147
- def cb ():
148
- pass
149
-
150
- with self .assertRaisesRegex (NotImplementedError ,
151
- 'requires Python 3.7' ):
152
- self .loop .call_soon (cb , context = 1 )
153
-
154
- with self .assertRaisesRegex (NotImplementedError ,
155
- 'requires Python 3.7' ):
156
- self .loop .call_soon_threadsafe (cb , context = 1 )
157
-
158
- with self .assertRaisesRegex (NotImplementedError ,
159
- 'requires Python 3.7' ):
160
- self .loop .call_later (0.1 , cb , context = 1 )
131
+ pass
161
132
162
133
163
134
class Test_AIO_Context (_ContextBaseTests , tb .AIOTestCase ):
0 commit comments