Пример #1
0
    def test_main_packageerrors_stderr(self, mock_run, mock_sys, mock_parser):
        # Doesn't matter so much what, just make sure it breaks
        mock_run.side_effect = hashin.PackageError('Some message here')

        error = hashin.main()
        self.assertEqual(error, 1)
        mock_sys.stderr.write.assert_any_call('Some message here')
        mock_sys.stderr.write.assert_any_call('\n')
Пример #2
0
 def test_main_version(self, mock_sys):
     mock_sys.argv = [None, '--version']
     my_stdout = StringIO()
     with redirect_stdout(my_stdout):
         error = hashin.main()
     self.assertEqual(error, 0)
     version = my_stdout.getvalue().strip()
     import pkg_resources
     current_version = pkg_resources.get_distribution('hashin').version
     # No easy way to know what exact version it is
     self.assertEqual(version, current_version)