def test_main(self):
     """ no args == error """
     with self.assertRaises(SystemExit) as cm:
         with capture_sys_output() as (stdout, stderr):
             main()
     self.assertEqual(cm.exception.code, 2)
     self.assertEqual(stdout.getvalue(), '')
     self.assertNotEqual(len(stderr.getvalue()), 0)
    def test_main_help(self):
        """ -h & --help work """
        with self.assertRaises(SystemExit) as cm:
            with capture_sys_output() as (stdout, stderr):
                main(['prog', '-h'])
        self.assertEqual(stderr.getvalue(), '')
        self.assertEqual(cm.exception.code, 0)
        self.assertNotEqual(len(stdout.getvalue()), 0)

        with self.assertRaises(SystemExit) as cm:
            with capture_sys_output() as (stdout, stderr):
                main(['prog', '--help'])
        self.assertEqual(cm.exception.code, 0)
        self.assertEqual(stderr.getvalue(), '')
        self.assertNotEqual(len(stdout.getvalue()), 0)