|
@@ -1,5 +1,6 @@ |
|
|
import argparse |
|
|
import argparse |
|
|
import asyncio |
|
|
import asyncio |
|
|
|
|
|
import io |
|
|
import multicast |
|
|
import multicast |
|
|
import sys |
|
|
import sys |
|
|
import unittest |
|
|
import unittest |
|
@@ -168,10 +169,15 @@ class TestLoraServ(unittest.IsolatedAsyncioTestCase): |
|
|
|
|
|
|
|
|
@timeout(2) |
|
|
@timeout(2) |
|
|
async def test_argerrors(self): |
|
|
async def test_argerrors(self): |
|
|
# it'd be nice to silence the usage output here |
|
|
|
|
|
with self.assertRaises(SystemExit) as cm, \ |
|
|
|
|
|
patch.dict(sys.__dict__, dict(argv=[ 'name', ])): |
|
|
|
|
|
await main() |
|
|
|
|
|
|
|
|
with io.StringIO() as fp: |
|
|
|
|
|
with self.assertRaises(SystemExit) as cm, \ |
|
|
|
|
|
patch.dict(sys.__dict__, dict(argv=[ 'name', ], |
|
|
|
|
|
stderr=fp)): |
|
|
|
|
|
await main() |
|
|
|
|
|
|
|
|
|
|
|
errout = fp.getvalue() |
|
|
|
|
|
|
|
|
|
|
|
self.assertEqual(errout, 'usage: name [-h] [-a maddr] serdev\nname: error: the following arguments are required: serdev\n') |
|
|
|
|
|
|
|
|
self.assertEqual(cm.exception.code, 2) |
|
|
self.assertEqual(cm.exception.code, 2) |
|
|
|
|
|
|
|
|