Skip to content

Commit 99ff0ba

Browse files
committed
Fix bug in pytest
1 parent 4f0cb88 commit 99ff0ba

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

pretty_verbose/__init__.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,20 @@ def format_message(self, message_type, message, decorator=" "):
148148
)
149149
return text
150150

151+
def get_terminal_columns(self):
152+
"""
153+
Return the number of columns of the terminal.
154+
155+
Returns
156+
-------
157+
Integer, number of columns of the terminal.
158+
159+
"""
160+
try:
161+
return os.get_terminal_size().columns
162+
except OSError:
163+
return 80
164+
151165
def log(
152166
self,
153167
min_level,
@@ -192,7 +206,7 @@ def log(
192206
print(
193207
(
194208
color + now + self.format_message(name, message, decorator)
195-
).ljust(os.get_terminal_size().columns),
209+
).ljust(self.get_terminal_columns()),
196210
end=end
197211
)
198212

0 commit comments

Comments
 (0)