Skip to content

Commit

Permalink
Allow override of DEFAULT_REPR_MAX_SIZE
Browse files Browse the repository at this point in the history
Fixes: #6682
  • Loading branch information
ssbarnea committed May 14, 2024
1 parent 93dd34e commit 65b3524
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ pip-wheel-metadata/

# pytest debug logs generated via --debug
pytestdebug.log

# other
.DS_Store
3 changes: 2 additions & 1 deletion src/_pytest/_io/saferepr.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import pprint
import reprlib
from typing import Optional
Expand Down Expand Up @@ -93,7 +94,7 @@ def safeformat(obj: object) -> str:


# Maximum size of overall repr of objects to display during assertion errors.
DEFAULT_REPR_MAX_SIZE = 240
DEFAULT_REPR_MAX_SIZE = int(os.environ.get("PYTEST_DEFAULT_REPR_MAX_SIZE", "240"))


def saferepr(
Expand Down
2 changes: 2 additions & 0 deletions src/_pytest/helpconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ def showhelp(config: Config) -> None:
("PYTEST_PLUGINS", "Comma-separated plugins to load during startup"),
("PYTEST_DISABLE_PLUGIN_AUTOLOAD", "Set to disable plugin auto-loading"),
("PYTEST_DEBUG", "Set to enable debug tracing of pytest's internals"),
("PYTEST_DEBUG", "Set to enable debug tracing of pytest's internals"),
("PYTEST_DEFAULT_REPR_MAX_SIZE", "Set custom size for using ellipsis to truncate long strings."),
]
for name, help in vars:
tw.line(f" {name:<24} {help}")
Expand Down

0 comments on commit 65b3524

Please sign in to comment.