def test_print_tty(self):
qr = qrcode.QRCode()
f = six.StringIO()
f.isatty = lambda: True
qr.print_tty(out=f)
printed = f.getvalue()
f.close()
BOLD_WHITE_BG = '\x1b[1;47m'
BLACK_BG = '\x1b[40m'
WHITE_BLOCK = BOLD_WHITE_BG + ' ' + BLACK_BG
EOL = '\x1b[0m\n'
expected = (
BOLD_WHITE_BG + ' '*23 + EOL +
WHITE_BLOCK + ' '*7 + WHITE_BLOCK)
self.assertEqual(printed[:len(expected)], expected)
评论列表
文章目录