terminalwriter: fix crash trying to highlight empty source
For quick checking I don't know how we can reach here with an empty source, so test just checks the function directly. Fix #11758.
This commit is contained in:
@@ -200,8 +200,9 @@ class TerminalWriter:
|
||||
"""Highlight the given source if we have markup support."""
|
||||
from _pytest.config.exceptions import UsageError
|
||||
|
||||
if not self.hasmarkup or not self.code_highlight:
|
||||
if not source or not self.hasmarkup or not self.code_highlight:
|
||||
return source
|
||||
|
||||
try:
|
||||
from pygments.formatters.terminal import TerminalFormatter
|
||||
|
||||
|
||||
Reference in New Issue
Block a user