briefing 0.2.2__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {briefing-0.2.2 → briefing-0.2.3}/CHANGELOG.md +13 -1
- {briefing-0.2.2 → briefing-0.2.3}/PKG-INFO +1 -1
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/__init__.py +1 -1
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/blocks/layout.py +21 -7
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/renderers/html.py +2 -2
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/renderers/table.py +6 -3
- {briefing-0.2.2 → briefing-0.2.3}/tests/contract.py +1 -1
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_blocks/test_layout.py +17 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_contract.py +6 -2
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_docs_gallery.py +1 -12
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_renderers/test_table.py +12 -0
- {briefing-0.2.2 → briefing-0.2.3}/.gitignore +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/LICENSE +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/README.md +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/noxfile.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/pyproject.toml +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/__main__.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/_cli.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/_error.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/_frames.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/_preview.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/blocks/__init__.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/blocks/asset.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/blocks/banner.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/blocks/base.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/blocks/text.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/export/__init__.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/export/_image.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/export/_pdf.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/export/_render.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/lab/__init__.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/lab/_blocks.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/lab/_render_calendar.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/lab/_render_datadive.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/lab/_render_profile.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/lab/static/calendar.js +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/lab/static/lab.js +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/py.typed +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/renderers/__init__.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/renderers/formatting.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/renderers/formula.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/renderers/normalize.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/renderers/plot.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/renderers/registry.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/renderers/script_json.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/static/export.css +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/static/export.js +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/static/report.css +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/static/report.js +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/src/briefing/templates/report.html.j2 +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/__init__.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/banner_images.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/compat_reports.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/conftest.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/html_helpers.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/image_helpers.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/pdf_reader.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/snapshots/compat_0_1_2/blocks.body.html +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/snapshots/compat_0_1_2/pages.body.html +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_blocks/__init__.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_blocks/test_banner.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_blocks/test_base.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_blocks/test_text.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_browser/__init__.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_browser/conftest.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_browser/test_banner.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_browser/test_bignumber.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_browser/test_calendar.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_browser/test_cli_export.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_browser/test_code.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_browser/test_datadive.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_browser/test_datatable.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_browser/test_export_image.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_browser/test_export_menu.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_browser/test_export_pdf.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_browser/test_formula.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_browser/test_layout.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_browser/test_notebook.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_browser/test_plots.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_browser/test_print.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_browser/test_spacing.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_browser/test_text.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_browser/test_toggle_theme.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_cli.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_compat.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_deprecations.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_docstrings.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_export.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_frames.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_lab/__init__.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_lab/test_calendar.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_lab/test_datadive.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_lab/test_lab_boundary.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_lab/test_profile.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_no_viz_deps.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_pdf_reader.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_preview.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_readme.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_renderers/__init__.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_renderers/test_export_menu.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_renderers/test_formula.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_renderers/test_html.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_renderers/test_normalize.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_renderers/test_plot.py +0 -0
- {briefing-0.2.2 → briefing-0.2.3}/tests/test_renderers/test_reproducible.py +0 -0
|
@@ -10,6 +10,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
10
10
|
|
|
11
11
|
## [Unreleased]
|
|
12
12
|
|
|
13
|
+
## [0.2.3] - 2026-11-07
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- `Group` rejects a `columns` that isn't a whole number of 1 or more, and `widths` that
|
|
18
|
+
aren't positive numbers, with a `BriefingError`. They used to be accepted and wrote invalid
|
|
19
|
+
CSS, so the browser dropped the layout without saying so (#98).
|
|
20
|
+
- `Table` with a pandas `Styler` gives the same bytes on every run: its ids and CSS selectors
|
|
21
|
+
come from the report instead of the random uuid pandas picks. The `Styler` you pass keeps
|
|
22
|
+
its own uuid (#101).
|
|
23
|
+
|
|
13
24
|
## [0.2.2] - 2026-11-04
|
|
14
25
|
|
|
15
26
|
### Added
|
|
@@ -240,7 +251,8 @@ First public release.
|
|
|
240
251
|
inherits its base's renderer.
|
|
241
252
|
- Ships inline type hints (`py.typed`). Python 3.11+.
|
|
242
253
|
|
|
243
|
-
[Unreleased]: https://github.com/jeanmidevacc/briefing/compare/v0.2.
|
|
254
|
+
[Unreleased]: https://github.com/jeanmidevacc/briefing/compare/v0.2.3...HEAD
|
|
255
|
+
[0.2.3]: https://github.com/jeanmidevacc/briefing/compare/v0.2.2...v0.2.3
|
|
244
256
|
[0.2.2]: https://github.com/jeanmidevacc/briefing/compare/v0.2.1...v0.2.2
|
|
245
257
|
[0.2.1]: https://github.com/jeanmidevacc/briefing/compare/v0.2.0...v0.2.1
|
|
246
258
|
[0.2.0]: https://github.com/jeanmidevacc/briefing/compare/v0.1.2...v0.2.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: briefing
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: Build beautiful self-contained HTML reports from Python analysis
|
|
5
5
|
Project-URL: Homepage, https://github.com/jeanmidevacc/briefing
|
|
6
6
|
Project-URL: Documentation, https://briefing.readthedocs.io
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"""Layout and container blocks: Group, Select, Toggle, Page, Briefing."""
|
|
2
2
|
from __future__ import annotations
|
|
3
3
|
|
|
4
|
+
import math
|
|
5
|
+
import numbers
|
|
4
6
|
import typing as t
|
|
5
7
|
import warnings
|
|
6
8
|
from collections.abc import Sequence
|
|
@@ -37,6 +39,12 @@ class VAlign(StrEnum):
|
|
|
37
39
|
BOTTOM = "bottom"
|
|
38
40
|
|
|
39
41
|
|
|
42
|
+
def _is_positive_number(value: object, *, whole: bool = False) -> bool:
|
|
43
|
+
"""Whether *value* is a finite number above zero; ``True`` and ``False`` don't count."""
|
|
44
|
+
kind = numbers.Integral if whole else numbers.Real
|
|
45
|
+
return isinstance(value, kind) and not isinstance(value, bool) and 0 < float(value) < math.inf
|
|
46
|
+
|
|
47
|
+
|
|
40
48
|
# ── layout blocks ─────────────────────────────────────────────────────────────
|
|
41
49
|
|
|
42
50
|
|
|
@@ -49,8 +57,8 @@ class Group(ContainerBlock):
|
|
|
49
57
|
Args:
|
|
50
58
|
*arg_blocks: The child blocks; strings become ``Text`` and dataframes ``DataTable``.
|
|
51
59
|
blocks: The children as a list, instead of positional arguments.
|
|
52
|
-
columns: Number of grid columns.
|
|
53
|
-
widths: Relative column widths, one per column (e.g. ``[2, 1]``).
|
|
60
|
+
columns: Number of grid columns, a whole number of 1 or more.
|
|
61
|
+
widths: Relative column widths, positive numbers, one per column (e.g. ``[2, 1]``).
|
|
54
62
|
valign: Vertical alignment of the cells: ``"top"``, ``"center"`` or ``"bottom"``.
|
|
55
63
|
name: Stable block id (letters, digits, ``_`` and ``-``), for referencing the block.
|
|
56
64
|
label: Tab or dropdown label when the block is inside a ``Select``.
|
|
@@ -73,12 +81,18 @@ class Group(ContainerBlock):
|
|
|
73
81
|
name: BlockId | None = None,
|
|
74
82
|
label: str | None = None,
|
|
75
83
|
) -> None:
|
|
76
|
-
if
|
|
77
|
-
raise BriefingError(
|
|
78
|
-
|
|
79
|
-
)
|
|
84
|
+
if not _is_positive_number(columns, whole=True):
|
|
85
|
+
raise BriefingError(f"Group 'columns' must be a whole number of 1 or more, not {columns!r}.")
|
|
86
|
+
if widths is not None:
|
|
87
|
+
if len(widths) != columns:
|
|
88
|
+
raise BriefingError(
|
|
89
|
+
f"Group 'widths' length ({len(widths)}) must match 'columns' ({columns})."
|
|
90
|
+
)
|
|
91
|
+
for width in widths:
|
|
92
|
+
if not _is_positive_number(width):
|
|
93
|
+
raise BriefingError(f"Group 'widths' must be positive numbers such as [2, 1], not {width!r}.")
|
|
80
94
|
super().__init__(*arg_blocks, blocks=blocks, name=name, label=label)
|
|
81
|
-
self.columns = columns
|
|
95
|
+
self.columns = int(columns)
|
|
82
96
|
self.widths = widths
|
|
83
97
|
self.valign = VAlign(valign)
|
|
84
98
|
|
|
@@ -317,8 +317,8 @@ def _render_plot(block: Plot, idgen: _IdGen) -> str:
|
|
|
317
317
|
|
|
318
318
|
|
|
319
319
|
@renderer_for(Table)
|
|
320
|
-
def _render_table(block: Table,
|
|
321
|
-
return render_table(block)
|
|
320
|
+
def _render_table(block: Table, idgen: _IdGen) -> str:
|
|
321
|
+
return render_table(block, idgen)
|
|
322
322
|
|
|
323
323
|
|
|
324
324
|
@renderer_for(DataTable)
|
|
@@ -19,6 +19,7 @@ HTML contains the full data set, so the table works offline forever.
|
|
|
19
19
|
"""
|
|
20
20
|
from __future__ import annotations
|
|
21
21
|
|
|
22
|
+
import copy
|
|
22
23
|
import html as _html
|
|
23
24
|
import math
|
|
24
25
|
import numbers
|
|
@@ -26,6 +27,7 @@ import typing as t
|
|
|
26
27
|
from datetime import date, timedelta
|
|
27
28
|
|
|
28
29
|
from briefing._error import BriefingError
|
|
30
|
+
from briefing.renderers.registry import IdGen
|
|
29
31
|
|
|
30
32
|
if t.TYPE_CHECKING:
|
|
31
33
|
from briefing.blocks.asset import DataTable, Table
|
|
@@ -100,7 +102,7 @@ def _use_index(df: t.Any) -> bool:
|
|
|
100
102
|
# ── static Table ──────────────────────────────────────────────────────────────
|
|
101
103
|
|
|
102
104
|
|
|
103
|
-
def render_table(block: Table) -> str:
|
|
105
|
+
def render_table(block: Table, idgen: IdGen | None = None) -> str:
|
|
104
106
|
"""Render a :class:`~briefing.Table` block to a static HTML table fragment."""
|
|
105
107
|
try:
|
|
106
108
|
from pandas.io.formats.style import Styler
|
|
@@ -112,8 +114,9 @@ def render_table(block: Table) -> str:
|
|
|
112
114
|
data = block.data
|
|
113
115
|
|
|
114
116
|
if isinstance(data, Styler):
|
|
115
|
-
#
|
|
116
|
-
|
|
117
|
+
# A full <style>+<table> fragment, used as it is apart from the id: pandas puts a random
|
|
118
|
+
# uuid in every id and selector. The copy leaves the caller's Styler as it was.
|
|
119
|
+
table_html = copy.copy(data).set_uuid((idgen or IdGen()).next("table")).to_html()
|
|
117
120
|
else:
|
|
118
121
|
table_html = data.to_html(
|
|
119
122
|
classes="bf-table__table",
|
|
@@ -150,7 +150,7 @@ RULES: dict[str, Callable[[Tag], None]] = {
|
|
|
150
150
|
|
|
151
151
|
|
|
152
152
|
def check_deterministic(render: Callable[[], str]) -> None:
|
|
153
|
-
"""Two
|
|
153
|
+
"""Two calls to *render* give byte-identical output (run with ``SOURCE_DATE_EPOCH`` set)."""
|
|
154
154
|
first, second = render(), render()
|
|
155
155
|
if first != second:
|
|
156
156
|
pairs = enumerate(zip(first, second, strict=False))
|
|
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
|
|
4
4
|
import warnings
|
|
5
5
|
|
|
6
|
+
import numpy as np
|
|
6
7
|
import pytest
|
|
7
8
|
|
|
8
9
|
from briefing._error import BriefingError
|
|
@@ -34,6 +35,22 @@ class TestGroup:
|
|
|
34
35
|
g = Group(blocks=items, columns=2)
|
|
35
36
|
assert len(g) == 2
|
|
36
37
|
|
|
38
|
+
@pytest.mark.parametrize("columns", [0, -1, 1.5, 2.0, True, "2", None])
|
|
39
|
+
def test_columns_must_be_a_whole_number_of_one_or_more(self, columns):
|
|
40
|
+
with pytest.raises(BriefingError, match="'columns' must be a whole number of 1 or more"):
|
|
41
|
+
Group(*make_texts(2), columns=columns)
|
|
42
|
+
|
|
43
|
+
@pytest.mark.parametrize("width", [0, -1, float("nan"), float("inf"), True, "1", None])
|
|
44
|
+
def test_widths_must_be_positive_numbers(self, width):
|
|
45
|
+
with pytest.raises(BriefingError, match="'widths' must be positive numbers"):
|
|
46
|
+
Group(*make_texts(2), columns=2, widths=[1, width])
|
|
47
|
+
|
|
48
|
+
@pytest.mark.parametrize(("columns", "widths"), [(np.int64(2), [np.int64(2), np.float64(1.5)])])
|
|
49
|
+
def test_numpy_numbers_work_like_python_ones(self, columns, widths):
|
|
50
|
+
g = Group(*make_texts(2), columns=columns, widths=widths)
|
|
51
|
+
assert g.columns == 2
|
|
52
|
+
assert type(g.columns) is int
|
|
53
|
+
|
|
37
54
|
def test_widths_correct_length(self):
|
|
38
55
|
g = Group(*make_texts(2), columns=2, widths=[2, 1])
|
|
39
56
|
assert g.widths == [2, 1]
|
|
@@ -130,6 +130,9 @@ SCENARIOS: dict[str, Build] = {
|
|
|
130
130
|
bf.Plot(_matplotlib_figure("line")), bf.Plot(_matplotlib_figure("bar"))
|
|
131
131
|
),
|
|
132
132
|
"table-styler": lambda df: bf.Briefing(bf.Table(df("df_constant").style.highlight_max(), caption="Styled")),
|
|
133
|
+
"two-table-stylers": lambda df: bf.Briefing(
|
|
134
|
+
bf.Table(df("df_constant").style.highlight_max()), bf.Table(df("df_constant").style.highlight_max())
|
|
135
|
+
),
|
|
133
136
|
**{
|
|
134
137
|
f"{kind}-{fixture}": _over_frame(make, fixture)
|
|
135
138
|
for kind, make in FRAME_BLOCKS.items()
|
|
@@ -208,8 +211,9 @@ def test_report_is_deterministic(
|
|
|
208
211
|
rule: str, scenario: str, frames: Frames, monkeypatch: pytest.MonkeyPatch
|
|
209
212
|
) -> None:
|
|
210
213
|
monkeypatch.setenv("SOURCE_DATE_EPOCH", "1700000000")
|
|
211
|
-
report
|
|
212
|
-
|
|
214
|
+
# Rebuild the report for each render: the promise is same input, same bytes. Rendering one
|
|
215
|
+
# object twice would miss randomness picked when a block or its data is created (#101).
|
|
216
|
+
check_deterministic(lambda: bf.stringify(SCENARIOS[scenario](frames), name=REPORT_NAME))
|
|
213
217
|
|
|
214
218
|
|
|
215
219
|
def _all_block_types() -> set[type]:
|
|
@@ -36,8 +36,6 @@ BY_ID = {example.id: example for example in EXAMPLES}
|
|
|
36
36
|
|
|
37
37
|
#: Rules every report fails today, as in tests/test_contract.py.
|
|
38
38
|
KNOWN_FAILURES = {"generator_meta": "#23: no generator meta tag yet"}
|
|
39
|
-
#: Examples whose output changes between runs today, by their ``:title:``.
|
|
40
|
-
NOT_DETERMINISTIC = {"A styled Table": "#101: a pandas Styler gets a random uuid"}
|
|
41
39
|
|
|
42
40
|
_reports: dict[str, str] = {}
|
|
43
41
|
|
|
@@ -67,16 +65,7 @@ def test_example_follows_rule(rule: str, example_id: str, tmp_path_factory: pyte
|
|
|
67
65
|
RULES[rule](parse_report(_report(example_id, tmp_path_factory)))
|
|
68
66
|
|
|
69
67
|
|
|
70
|
-
|
|
71
|
-
cases = []
|
|
72
|
-
for ex in EXAMPLES:
|
|
73
|
-
reason = NOT_DETERMINISTIC.get(ex.options.get("title", ""))
|
|
74
|
-
marks = [pytest.mark.xfail(reason=reason, strict=True)] if reason else []
|
|
75
|
-
cases.append(pytest.param(ex.id, marks=marks, id=ex.id))
|
|
76
|
-
return cases
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
@pytest.mark.parametrize("example_id", _deterministic_cases())
|
|
68
|
+
@pytest.mark.parametrize("example_id", [ex.id for ex in EXAMPLES])
|
|
80
69
|
def test_example_is_deterministic(example_id: str, tmp_path_factory: pytest.TempPathFactory) -> None:
|
|
81
70
|
again = gallery.run_example(BY_ID[example_id].code, tmp_path_factory.mktemp("again"), where=example_id)
|
|
82
71
|
assert again.read_text(encoding="utf-8") == _report(example_id, tmp_path_factory)
|
|
@@ -79,6 +79,18 @@ class TestRenderTable:
|
|
|
79
79
|
html = render_table(Table(styler))
|
|
80
80
|
assert "<table" in html
|
|
81
81
|
|
|
82
|
+
def test_equal_stylers_render_the_same_bytes(self, simple_df):
|
|
83
|
+
first, second = (render_table(Table(simple_df.style.highlight_max())) for _ in range(2))
|
|
84
|
+
assert first == second
|
|
85
|
+
|
|
86
|
+
def test_rendering_leaves_the_stylers_uuid_alone(self, simple_df):
|
|
87
|
+
styler = simple_df.style.highlight_max()
|
|
88
|
+
own_uuid = styler.uuid
|
|
89
|
+
html = render_table(Table(styler))
|
|
90
|
+
assert styler.uuid == own_uuid
|
|
91
|
+
assert own_uuid not in html
|
|
92
|
+
assert f"T_{own_uuid}" in styler.to_html()
|
|
93
|
+
|
|
82
94
|
def test_rangeindex_hidden_by_default(self, simple_df):
|
|
83
95
|
# Default RangeIndex should not appear as a column
|
|
84
96
|
html = render_table(Table(simple_df))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|