示例#1
0
 def test_stdin_py3_unicodedecodeerror(self, mock_print_ascii):
     mock_stdin = mock.Mock(sys.stdin)
     mock_stdin.buffer.read.return_value = 'testtext'
     mock_stdin.read.side_effect = bad_read
     with mock.patch('sys.stdin', mock_stdin):
         main([])
     mock_print_ascii.assert_called_with(tty=True)
示例#2
0
 def test_stdin_py3_unicodedecodeerror(self, mock_print_ascii):
     mock_stdin = mock.Mock(sys.stdin)
     mock_stdin.buffer.read.return_value = "testtext"
     mock_stdin.read.side_effect = bad_read
     with mock.patch("sys.stdin", mock_stdin):
         main([])
     mock_print_ascii.assert_called_with(tty=True)
示例#3
0
 def test_stdin(self, mock_print_ascii):
     mock_stdin = mock.Mock()
     mock_stdin.configure_mock(**{'read.return_value': 'testtext'})
     with mock.patch('sys.stdin', mock_stdin) as stdin:
         main([])
         self.assertTrue(stdin.read.called)
     mock_print_ascii.assert_called_with(tty=True)
 def test_stdin(self, mock_print_ascii):
     mock_stdin = mock.Mock()
     mock_stdin.configure_mock(**{'read.return_value': 'testtext'})
     with mock.patch('sys.stdin', mock_stdin) as stdin:
         main([])
         self.assertTrue(stdin.read.called)
     mock_print_ascii.assert_called_with(tty=True)
示例#5
0
 def test_stdin(self, mock_print_ascii):
     mock_stdin = mock.Mock(sys.stdin)
     stdin_buffer = getattr(mock_stdin, 'buffer', mock_stdin)
     stdin_buffer.read.return_value = 'testtext'
     with mock.patch('sys.stdin', mock_stdin):
         main([])
     self.assertTrue(stdin_buffer.read.called)
     mock_print_ascii.assert_called_with(tty=True)
示例#6
0
 def test_stdin(self, mock_print_ascii):
     mock_stdin = mock.Mock(sys.stdin)
     stdin_buffer = getattr(mock_stdin, 'buffer', mock_stdin)
     stdin_buffer.read.return_value = 'testtext'
     with mock.patch('sys.stdin', mock_stdin):
         main([])
     self.assertTrue(stdin_buffer.read.called)
     mock_print_ascii.assert_called_with(tty=True)
示例#7
0
 def test_stdin_py3_unicodedecodeerror(self, mock_print_ascii):
     mock_stdin = mock.Mock(sys.stdin)
     mock_stdin.buffer.read.return_value = 'testtext'
     mock_stdin.read.side_effect = bad_read
     with mock.patch('sys.stdin', mock_stdin):
         # sys.stdin.read() will raise an error...
         self.assertRaises(UnicodeDecodeError, sys.stdin.read)
         # ... but it won't be used now.
         main([])
     mock_print_ascii.assert_called_with(tty=True)
示例#8
0
 def test_stdin_py3_unicodedecodeerror(self, mock_print_ascii):
     mock_stdin = mock.Mock(sys.stdin)
     mock_stdin.buffer.read.return_value = 'testtext'
     mock_stdin.read.side_effect = bad_read
     with mock.patch('sys.stdin', mock_stdin):
         # sys.stdin.read() will raise an error...
         self.assertRaises(UnicodeDecodeError, sys.stdin.read)
         # ... but it won't be used now.
         main([])
     mock_print_ascii.assert_called_with(tty=True)
示例#9
0
 def test_piped(self, mock_stdout):
     main(['testtext'])
示例#10
0
 def test_isatty(self, mock_print_ascii):
     main(['testtext'])
     mock_print_ascii.assert_called_with(tty=True)
示例#11
0
 def test_factory(self, mock_stdout):
     main('testtext --factory svg'.split())
 def test_piped(self, mock_stdout):
     main(['testtext'])
 def test_isatty(self, mock_print_ascii):
     main(['testtext'])
     mock_print_ascii.assert_called_with(tty=True)
示例#14
0
    def show_qrcode(self, user: str, issuer: str):
        from qrcode import console_scripts

        console_scripts.main([self.generate_uri(user, issuer)])
 def test_optimize(self, mock_print_ascii):
     main('testtext --optimize 0'.split())
示例#16
0
 def test_optimize(self, mock_print_ascii):
     main('testtext --optimize 0'.split())
 def test_factory(self, mock_stdout):
     main('testtext --factory svg'.split())
示例#18
0
 def test_output(self):
     tmpfile = os.path.join(self.tmpdir, "test.png")
     main(['testtext', '--output', tmpfile])
     os.remove(tmpfile)
示例#19
0
 def test_piped(self, mock_stdout):
     main(["testtext"])