mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
Drop Python 3.4 and switch to async / await syntax for asyncio. Fixes #1425
This commit is contained in:
1 parent
8baa480b79
commit
76af98404a
119 files changed
+2432
-3084
No files matched your search
@@ -23,27 +23,26 @@ from gns3server.utils.asyncio.embed_shell import EmbedShell
|
||||
def test_embed_shell_help(async_run):
|
||||
class Application(EmbedShell):
|
||||
|
||||
@asyncio.coroutine
|
||||
def hello(self):
|
||||
async def hello(self):
|
||||
"""
|
||||
The hello world function
|
||||
|
||||
The hello usage
|
||||
"""
|
||||
pass
|
||||
await asyncio.sleep(1)
|
||||
|
||||
reader = asyncio.StreamReader()
|
||||
writer = asyncio.StreamReader()
|
||||
app = Application(reader, writer)
|
||||
assert async_run(app._parse_command('help')) == 'Help:\nhello: The hello world function\nhelp: Show help\n\nhelp command for details about a command\n'
|
||||
assert async_run(app._parse_command('?')) == 'Help:\nhello: The hello world function\nhelp: Show help\n\nhelp command for details about a command\n'
|
||||
assert async_run(app._parse_command('help')) == 'Help:\nhello: The hello world function\n\nhelp command for details about a command\n'
|
||||
assert async_run(app._parse_command('?')) == 'Help:\nhello: The hello world function\n\nhelp command for details about a command\n'
|
||||
assert async_run(app._parse_command('? hello')) == 'hello: The hello world function\n\nThe hello usage\n'
|
||||
|
||||
|
||||
def test_embed_shell_execute(async_run):
|
||||
class Application(EmbedShell):
|
||||
|
||||
@asyncio.coroutine
|
||||
def hello(self):
|
||||
async def hello(self):
|
||||
"""
|
||||
The hello world function
|
||||
|
||||
|
||||
@@ -85,10 +85,9 @@ def test_lock_decorator(loop):
|
||||
self._test_val = 0
|
||||
|
||||
@locking
|
||||
@asyncio.coroutine
|
||||
def method_to_lock(self):
|
||||
async def method_to_lock(self):
|
||||
res = self._test_val
|
||||
yield from asyncio.sleep(0.1)
|
||||
await asyncio.sleep(0.1)
|
||||
self._test_val += 1
|
||||
return res
|
||||
|
||||
|
||||
Reference in new issue
Block a user