From 3b1518f943f36c45a4a88e9f791fdf0cb332cc24 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Sat, 26 Feb 2022 19:03:23 +0000 Subject: [PATCH] sorted --- CHANGELOG.md | 9 +++++---- rich/pretty.py | 1 + tests/test_pretty.py | 17 ++++++++++++++--- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c5c243a..91c1741a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,18 +10,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added ProgressColumn `MofNCompleteColumn` to display raw `completed/total` column (similar to DownloadColumn, - but displays values as ints, does not convert to floats or add bit/bytes units). + but displays values as ints, does not convert to floats or add bit/bytes units). https://github.com/Textualize/rich/pull/1941 ### Fixed -- In Jupyter mode make the link target be set to "_blank" +- In Jupyter mode make the link target be set to "\_blank" - Fix some issues with markup handling around "[" characters https://github.com/Textualize/rich/pull/1950 - Fix syntax lexer guessing. +- Fixed Pretty measure not respecting expand_all https://github.com/Textualize/rich/issues/1998 -### Added +### Change -- Add support for enum.Flag in ReprHighlighter https://github.com/Textualize/rich/pull/1920 +- Improved support for enum.Flag in ReprHighlighter https://github.com/Textualize/rich/pull/1920 ## [11.2.0] - 2022-02-08 diff --git a/rich/pretty.py b/rich/pretty.py index f42434ef..216075af 100644 --- a/rich/pretty.py +++ b/rich/pretty.py @@ -323,6 +323,7 @@ class Pretty(JupyterMixin): indent_size=self.indent_size, max_length=self.max_length, max_string=self.max_string, + expand_all=self.expand_all, ) text_width = ( max(cell_len(line) for line in pretty_str.splitlines()) if pretty_str else 0 diff --git a/tests/test_pretty.py b/tests/test_pretty.py index 871f1397..02488f46 100644 --- a/tests/test_pretty.py +++ b/tests/test_pretty.py @@ -1,15 +1,16 @@ import io import sys from array import array -from collections import defaultdict, UserDict +from collections import UserDict, defaultdict +from dataclasses import dataclass, field from typing import List import attr import pytest -from dataclasses import dataclass, field from rich.console import Console -from rich.pretty import install, Pretty, pprint, pretty_repr, Node, _ipy_display_hook +from rich.measure import Measurement +from rich.pretty import Node, Pretty, _ipy_display_hook, install, pprint, pretty_repr from rich.text import Text skip_py36 = pytest.mark.skipif( @@ -464,3 +465,13 @@ def test_lying_attribute(): foo = Foo() result = pretty_repr(foo) assert "Foo" in result + + +def test_measure_pretty(): + """Test measure respects expand_all""" + # https://github.com/Textualize/rich/issues/1998 + console = Console() + pretty = Pretty(["alpha", "beta", "delta", "gamma"], expand_all=True) + + measurement = console.measure(pretty) + assert measurement == Measurement(12, 12)