Browse Source

clean up test output, and verify that the error message is correct..

main
John-Mark Gurney 1 year ago
parent
commit
2ea0bcd42a
1 changed files with 10 additions and 4 deletions
  1. +10
    -4
      loraserv.py

+ 10
- 4
loraserv.py View File

@@ -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)




Loading…
Cancel
Save