forked from mirrors/gecko-dev
MozReview-Commit-ID: 5qfK6OygVMH --HG-- rename : third_party/python/pytest/_pytest/vendored_packages/pluggy-0.4.0.dist-info/LICENSE.txt => third_party/python/pluggy/LICENSE rename : third_party/python/pytest/doc/en/example/costlysetup/sub1/__init__.py => third_party/python/pytest/doc/en/example/costlysetup/sub_a/__init__.py rename : third_party/python/pytest/doc/en/example/costlysetup/sub1/__init__.py => third_party/python/pytest/doc/en/example/costlysetup/sub_b/__init__.py rename : third_party/python/pytest/_pytest/_code/__init__.py => third_party/python/pytest/src/_pytest/_code/__init__.py extra : rebase_source : d80873f2b1899decefbddddfc2f69ae045925b81
37 lines
931 B
Python
37 lines
931 B
Python
import logging
|
|
|
|
import py.io
|
|
from _pytest.logging import ColoredLevelFormatter
|
|
|
|
|
|
def test_coloredlogformatter():
|
|
logfmt = "%(filename)-25s %(lineno)4d %(levelname)-8s %(message)s"
|
|
|
|
record = logging.LogRecord(
|
|
name="dummy",
|
|
level=logging.INFO,
|
|
pathname="dummypath",
|
|
lineno=10,
|
|
msg="Test Message",
|
|
args=(),
|
|
exc_info=False,
|
|
)
|
|
|
|
class ColorConfig(object):
|
|
|
|
class option(object):
|
|
pass
|
|
|
|
tw = py.io.TerminalWriter()
|
|
tw.hasmarkup = True
|
|
formatter = ColoredLevelFormatter(tw, logfmt)
|
|
output = formatter.format(record)
|
|
assert (
|
|
output
|
|
== ("dummypath 10 " "\x1b[32mINFO \x1b[0m Test Message")
|
|
)
|
|
|
|
tw.hasmarkup = False
|
|
formatter = ColoredLevelFormatter(tw, logfmt)
|
|
output = formatter.format(record)
|
|
assert output == ("dummypath 10 " "INFO Test Message")
|