Пример #1
0
    def test_rg(self, plot_patch):
        impplot.sys.argv = ['dummy', 'rg', 'fn']
        impplot.main()
        self.assertTrue(plot_patch.called)
        aca, kwca = plot_patch.call_args
        self.assertEqual(aca[0], ['fn'])

        # we can let these default, but if touched must be None
        if 'power' in kwca:
            self.assertIsNone(kwca['power'])
        if 'tr' in kwca:
            self.assertIsNone(kwca['tr'])
Пример #2
0
    def test_power(self, plot_patch):
        impplot.sys.argv = ['dummy', 'power', 'fn', '16']
        impplot.main()
        self.assertTrue(plot_patch.called)
        aca, kwca = plot_patch.call_args
        self.assertEqual(aca[0], ['fn'])
        self.assertEqual(kwca['power'], 16)
        if 'tr' in kwca:
            self.assertIsNone(kwca['tr'])

        impplot.sys.argv = ['dummy', 'power', 'fn', '16.']
        with self.assertRaises(SystemExit):
            impplot.main()
Пример #3
0
    def test_traces(self, plot_patch):
        impplot.sys.argv = ['dummy', 'traces', 'fn', '8', '16']
        impplot.main()
        self.assertTrue(plot_patch.called)
        aca, kwca = plot_patch.call_args
        self.assertEqual(aca[0], ['fn'])
        self.assertEqual(kwca['tr'], (8, 16))
        if 'power' in kwca:
            self.assertIsNone(kwca['power'])

        impplot.sys.argv = ['dummy', 'traces', 'fn', '8', '16.']

        argparse_mock = MagicMock()
        with patch('argparse.ArgumentParser._print_message', argparse_mock):
            with self.assertRaises(SystemExit):
                impplot.main()

        impplot.sys.argv = ['dummy', 'traces', 'fn', '8.', '16']

        argparse_mock = MagicMock()
        with patch('argparse.ArgumentParser._print_message', argparse_mock):
            with self.assertRaises(SystemExit):
                impplot.main()

        impplot.sys.argv = ['dummy', 'traces', 'fn', '8']

        argparse_mock = MagicMock()
        with patch('argparse.ArgumentParser._print_message', argparse_mock):
            with self.assertRaises(BaseException):
                impplot.main()
Пример #4
0
    def test_badinput(self, plot_patch):
        impplot.sys.argv = ['dummy']

        argparse_mock = MagicMock()
        with patch('argparse.ArgumentParser._print_message', argparse_mock):
            with self.assertRaises(BaseException):
                impplot.main()

        impplot.sys.argv = ['dummy', 'dummy']
        argparse_mock = MagicMock()
        with patch('argparse.ArgumentParser._print_message', argparse_mock):
            with self.assertRaises(BaseException):
                impplot.main()

        impplot.sys.argv = ['dummy', 'rg']
        argparse_mock = MagicMock()
        with patch('argparse.ArgumentParser._print_message', argparse_mock):
            with self.assertRaises(BaseException):
                impplot.main()

        impplot.sys.argv = ['dummy', 'dummy', 'fn']

        argparse_mock = MagicMock()
        with patch('argparse.ArgumentParser._print_message', argparse_mock):
            with self.assertRaises(SystemExit):
                impplot.main()
Пример #5
0
    def test_badinput(self, plot_patch):
        impplot.sys.argv = ['dummy']
        with self.assertRaises(BaseException):
            impplot.main()

        impplot.sys.argv = ['dummy', 'dummy']
        with self.assertRaises(BaseException):
            impplot.main()

        impplot.sys.argv = ['dummy', 'rg']
        with self.assertRaises(BaseException):
            impplot.main()

        impplot.sys.argv = ['dummy', 'dummy', 'fn']
        with self.assertRaises(SystemExit):
            impplot.main()
Пример #6
0
    def test_traces(self, plot_patch):
        impplot.sys.argv = ['dummy', 'traces', 'fn', '8', '16']
        impplot.main()
        self.assertTrue(plot_patch.called)
        aca, kwca = plot_patch.call_args
        self.assertEqual(aca[0], ['fn'])
        self.assertEqual(kwca['tr'], (8, 16))
        if 'power' in kwca:
            self.assertIsNone(kwca['power'])

        impplot.sys.argv = ['dummy', 'traces', 'fn', '8', '16.']
        with self.assertRaises(SystemExit):
            impplot.main()

        impplot.sys.argv = ['dummy', 'traces', 'fn', '8.', '16']
        with self.assertRaises(SystemExit):
            impplot.main()

        impplot.sys.argv = ['dummy', 'traces', 'fn', '8']
        with self.assertRaises(BaseException):
            impplot.main()