make py.io.ansi_print and py.io.get_terminal_width() directly available.
--HG-- branch : trunk
This commit is contained in:
parent
030548bc73
commit
5dc66bb4ca
|
@ -138,6 +138,8 @@ py.apipkg.initpkg(__name__, dict(
|
|||
'StdCapture' : '._io.capture:StdCapture',
|
||||
'StdCaptureFD' : '._io.capture:StdCaptureFD',
|
||||
'TerminalWriter' : '._io.terminalwriter:TerminalWriter',
|
||||
'ansi_print' : '._io.terminalwriter:ansi_print',
|
||||
'get_terminal_width' : '._io.terminalwriter:get_terminal_width',
|
||||
},
|
||||
|
||||
# small and mean xml/html generation
|
||||
|
|
|
@ -9,7 +9,7 @@ prepended."""
|
|||
|
||||
import sys, os
|
||||
import py
|
||||
from py._io.terminalwriter import ansi_print, terminal_width
|
||||
from py.io import ansi_print, get_terminal_width
|
||||
import re
|
||||
|
||||
def rec(p):
|
||||
|
@ -21,6 +21,8 @@ parser.add_option("-i", "--ignore-case", action="store_true", dest="ignorecase",
|
|||
parser.add_option("-C", "--context", action="store", type="int", dest="context",
|
||||
default=0, help="How many lines of output to show")
|
||||
|
||||
terminal_width = get_terminal_width()
|
||||
|
||||
def find_indexes(search_line, string):
|
||||
indexes = []
|
||||
before = 0
|
||||
|
|
|
@ -2,6 +2,10 @@ import py
|
|||
import os, sys
|
||||
from py._io import terminalwriter
|
||||
|
||||
def test_get_terminal_width():
|
||||
x = py.io.get_terminal_width
|
||||
assert x == terminalwriter.get_terminal_width
|
||||
|
||||
def test_terminal_width_COLUMNS(monkeypatch):
|
||||
""" Dummy test for get_terminal_width
|
||||
"""
|
||||
|
@ -147,3 +151,13 @@ def test_attr_hasmarkup():
|
|||
tw.line("hello", bold=True)
|
||||
s = tw.stringio.getvalue()
|
||||
assert len(s) > len("hello")
|
||||
|
||||
def test_ansi_print():
|
||||
# we have no easy way to construct a file that
|
||||
# represents a terminal
|
||||
f = py.io.TextIO()
|
||||
f.isatty = lambda: True
|
||||
py.io.ansi_print("hello", 0x32, file=f)
|
||||
text2 = f.getvalue()
|
||||
assert text2.find("hello") != -1
|
||||
assert len(text2) >= len("hello")
|
||||
|
|
Loading…
Reference in New Issue