| 35 | |
| 36 | @mock.patch("os.isatty", lambda *args: True) |
| 37 | def test_stdin_py3_unicodedecodeerror(): |
| 38 | with mock.patch("qrcode.main.QRCode.print_ascii") as mock_print_ascii: |
| 39 | with mock.patch("sys.stdin") as mock_stdin: |
| 40 | mock_stdin.buffer.read.return_value = "testtext" |
| 41 | mock_stdin.read.side_effect = bad_read |
| 42 | # sys.stdin.read() will raise an error... |
| 43 | with pytest.raises(UnicodeDecodeError): |
| 44 | sys.stdin.read() |
| 45 | # ... but it won't be used now. |
| 46 | main([]) |
| 47 | mock_print_ascii.assert_called_with(tty=True) |
| 48 | |
| 49 | |
| 50 | def test_optimize(): |