mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Move `test_log_no_ansi_colors
`
This commit is contained in:
parent
bb5716b54a
commit
baddae6611
@ -2,17 +2,11 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from contextlib import contextmanager
|
||||
|
||||
import pytest
|
||||
from docutils import nodes
|
||||
|
||||
from sphinx.cmd.build import build_main
|
||||
from sphinx.errors import SphinxError
|
||||
|
||||
from tests.utils import TESTS_ROOT
|
||||
|
||||
|
||||
def test_root_doc_not_found(tmp_path, make_app):
|
||||
(tmp_path / 'conf.py').touch()
|
||||
@ -110,29 +104,3 @@ def test_image_glob(app):
|
||||
'image/svg+xml': 'subdir/svgimg.svg',
|
||||
}
|
||||
assert doctree[0][3][0]['uri'] == 'subdir/svgimg.*'
|
||||
|
||||
|
||||
@contextmanager
|
||||
def force_colors():
|
||||
forcecolor = os.environ.get('FORCE_COLOR', None)
|
||||
|
||||
try:
|
||||
os.environ['FORCE_COLOR'] = '1'
|
||||
yield
|
||||
finally:
|
||||
if forcecolor is None:
|
||||
os.environ.pop('FORCE_COLOR', None)
|
||||
else:
|
||||
os.environ['FORCE_COLOR'] = forcecolor
|
||||
|
||||
|
||||
def test_log_no_ansi_colors(tmp_path):
|
||||
with force_colors():
|
||||
wfile = tmp_path / 'warnings.txt'
|
||||
srcdir = TESTS_ROOT / 'roots' / 'test-nitpicky-warnings'
|
||||
argv = list(map(str, ['-b', 'html', srcdir, tmp_path, '-n', '-w', wfile]))
|
||||
retcode = build_main(argv)
|
||||
assert retcode == 0
|
||||
|
||||
content = wfile.read_text(encoding='utf8')
|
||||
assert '\x1b[91m' not in content
|
||||
|
@ -4,17 +4,21 @@ from __future__ import annotations
|
||||
|
||||
import codecs
|
||||
import os
|
||||
from contextlib import contextmanager
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from docutils import nodes
|
||||
|
||||
from sphinx._cli.util.errors import strip_escape_sequences
|
||||
from sphinx.cmd.build import build_main
|
||||
from sphinx.util import logging
|
||||
from sphinx.util.console import colorize
|
||||
from sphinx.util.logging import is_suppressed_warning, prefixed_warnings
|
||||
from sphinx.util.parallel import ParallelTasks
|
||||
|
||||
from tests.utils import TESTS_ROOT
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_info_and_warning(app):
|
||||
@ -276,6 +280,32 @@ def test_pending_warnings(app):
|
||||
assert 'WARNING: message2\nWARNING: message3' in warnings
|
||||
|
||||
|
||||
@contextmanager
|
||||
def force_colors():
|
||||
forcecolor = os.environ.get('FORCE_COLOR', None)
|
||||
|
||||
try:
|
||||
os.environ['FORCE_COLOR'] = '1'
|
||||
yield
|
||||
finally:
|
||||
if forcecolor is None:
|
||||
os.environ.pop('FORCE_COLOR', None)
|
||||
else:
|
||||
os.environ['FORCE_COLOR'] = forcecolor
|
||||
|
||||
|
||||
def test_log_no_ansi_colors(tmp_path):
|
||||
with force_colors():
|
||||
wfile = tmp_path / 'warnings.txt'
|
||||
srcdir = TESTS_ROOT / 'roots' / 'test-nitpicky-warnings'
|
||||
argv = list(map(str, ['-b', 'html', srcdir, tmp_path, '-n', '-w', wfile]))
|
||||
retcode = build_main(argv)
|
||||
assert retcode == 0
|
||||
|
||||
content = wfile.read_text(encoding='utf8')
|
||||
assert '\x1b[91m' not in content
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_colored_logs(app):
|
||||
app.verbosity = 2
|
||||
|
Loading…
Reference in New Issue
Block a user