-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy path3.7.py
More file actions
executable file
·47 lines (33 loc) · 825 Bytes
/
3.7.py
File metadata and controls
executable file
·47 lines (33 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python3.7
# https://docs.python.org/3/whatsnew/3.7.html
# https://realpython.com/python37-new-features/
import asyncio
import sys
from contextvars import ContextVar
import dataclasses
import importlib.resources
from passed import passed
var: ContextVar[int] = ContextVar('var', default=1)
assert var.get() == 1
var.set(2)
assert var.get() == 2
buf = ''
async def corutine():
global buf
buf += '3'
async def test_task():
global buf
buf += '1'
# Before:
# task = asyncio.ensure_future(corutine())
task = asyncio.create_task(corutine())
buf += '2'
await task
buf += '4'
asyncio.run(test_task())
assert buf == '1234'
breakpoint_passed = False
sys.breakpointhook = lambda: globals().update(breakpoint_passed=True)
breakpoint()
assert breakpoint_passed
passed()