behave-modern-html-report 1.0.0__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.
Files changed (42) hide show
  1. behave_modern_html_report-1.0.0/.gitignore +26 -0
  2. behave_modern_html_report-1.0.0/CHANGELOG.md +40 -0
  3. behave_modern_html_report-1.0.0/LICENSE +21 -0
  4. behave_modern_html_report-1.0.0/PKG-INFO +179 -0
  5. behave_modern_html_report-1.0.0/README.md +150 -0
  6. behave_modern_html_report-1.0.0/behave_modern_html_report/__init__.py +42 -0
  7. behave_modern_html_report-1.0.0/behave_modern_html_report/assets/css/report.css +410 -0
  8. behave_modern_html_report-1.0.0/behave_modern_html_report/assets/js/charts.js +251 -0
  9. behave_modern_html_report-1.0.0/behave_modern_html_report/assets/js/report.js +246 -0
  10. behave_modern_html_report-1.0.0/behave_modern_html_report/assets.py +78 -0
  11. behave_modern_html_report-1.0.0/behave_modern_html_report/attach.py +194 -0
  12. behave_modern_html_report-1.0.0/behave_modern_html_report/collector.py +266 -0
  13. behave_modern_html_report-1.0.0/behave_modern_html_report/formatter.py +218 -0
  14. behave_modern_html_report-1.0.0/behave_modern_html_report/models.py +276 -0
  15. behave_modern_html_report-1.0.0/behave_modern_html_report/renderer.py +213 -0
  16. behave_modern_html_report-1.0.0/behave_modern_html_report/statistics.py +218 -0
  17. behave_modern_html_report-1.0.0/behave_modern_html_report/templates/components/_scenario_item.html.jinja +34 -0
  18. behave_modern_html_report-1.0.0/behave_modern_html_report/templates/components/dashboard.html.jinja +60 -0
  19. behave_modern_html_report-1.0.0/behave_modern_html_report/templates/components/environment.html.jinja +27 -0
  20. behave_modern_html_report-1.0.0/behave_modern_html_report/templates/components/feature.html.jinja +40 -0
  21. behave_modern_html_report-1.0.0/behave_modern_html_report/templates/components/icons.html.jinja +24 -0
  22. behave_modern_html_report-1.0.0/behave_modern_html_report/templates/components/scenario.html.jinja +13 -0
  23. behave_modern_html_report-1.0.0/behave_modern_html_report/templates/components/statistics.html.jinja +22 -0
  24. behave_modern_html_report-1.0.0/behave_modern_html_report/templates/components/step.html.jinja +71 -0
  25. behave_modern_html_report-1.0.0/behave_modern_html_report/templates/components/tags.html.jinja +62 -0
  26. behave_modern_html_report-1.0.0/behave_modern_html_report/templates/report.html.jinja +99 -0
  27. behave_modern_html_report-1.0.0/behave_modern_html_report/utils.py +73 -0
  28. behave_modern_html_report-1.0.0/docs/architecture.md +48 -0
  29. behave_modern_html_report-1.0.0/docs/contributing.md +66 -0
  30. behave_modern_html_report-1.0.0/examples/behave.ini +7 -0
  31. behave_modern_html_report-1.0.0/examples/features/example.feature +18 -0
  32. behave_modern_html_report-1.0.0/examples/features/steps/example_steps.py +22 -0
  33. behave_modern_html_report-1.0.0/examples/generate_demo.py +132 -0
  34. behave_modern_html_report-1.0.0/pyproject.toml +76 -0
  35. behave_modern_html_report-1.0.0/tests/__init__.py +1 -0
  36. behave_modern_html_report-1.0.0/tests/conftest.py +90 -0
  37. behave_modern_html_report-1.0.0/tests/test_attach.py +84 -0
  38. behave_modern_html_report-1.0.0/tests/test_collector.py +140 -0
  39. behave_modern_html_report-1.0.0/tests/test_models.py +54 -0
  40. behave_modern_html_report-1.0.0/tests/test_renderer.py +66 -0
  41. behave_modern_html_report-1.0.0/tests/test_statistics.py +92 -0
  42. behave_modern_html_report-1.0.0/tests/test_utils.py +18 -0
@@ -0,0 +1,26 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .eggs/
5
+ build/
6
+ dist/
7
+ .venv/
8
+ venv/
9
+ .env
10
+ .tox/
11
+ .coverage
12
+ .coverage.*
13
+ htmlcov/
14
+ .pytest_cache/
15
+ .ruff_cache/
16
+ .mypy_cache/
17
+
18
+ # Generated artifacts
19
+ examples/demo-report.html
20
+ report.html
21
+ *.html.bak
22
+
23
+ # IDE
24
+ .vscode/
25
+ .idea/
26
+ *.swp
@@ -0,0 +1,40 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.2.0] - 2026-06-28
9
+
10
+ ### Added
11
+
12
+ - New **Tags** page with per-tag scenario counts, pass rate, duration, and a pass-rate chart.
13
+ - `behave_modern_html_report.attach` helper API: `attach_screenshot`, `attach_file`, `attach_text`, `attach_json`, `log` for easy `environment.py` integration.
14
+ - **JSON sidecar output** (`bmr.json_sidecar = true`) writes `report.json` next to the HTML report.
15
+ - Inline step duration bar showing each step's relative cost within the scenario.
16
+ - Copy-reproduce-command button on every scenario (`behave features/example.feature:3`).
17
+
18
+ ### Changed
19
+
20
+ - Promoted PyPI classifier from `Beta` to `Production/Stable`.
21
+ - README badges now point to PyPI and CI.
22
+
23
+ ## [0.1.0] - 2026-06-28
24
+
25
+ ### Added
26
+
27
+ - Initial release of **Behave Modern Report**.
28
+ - Layered architecture: `formatter`, `collector`, `models`, `statistics`, `renderer`, `assets`.
29
+ - Single-file, fully offline HTML report.
30
+ - Dark / Light / Auto themes.
31
+ - Dashboard with execution summary and environment metadata.
32
+ - Interactive Chart.js statistics (status pie, duration bar, slowest scenarios).
33
+ - Sidebar navigation: Dashboard, Features, Scenarios, Statistics, Environment.
34
+ - Client-side instant search and multi-criteria filtering.
35
+ - Expandable features, scenarios and steps with rich metadata.
36
+ - Modern error viewer with copy-to-clipboard.
37
+ - Attachment support (images, text, JSON, etc.) with lightbox gallery.
38
+ - Configurable title, company, logo, custom CSS/JS.
39
+ - Accessibility: keyboard navigation, ARIA labels, high-contrast palette.
40
+ - GitHub Actions CI workflow (ruff + pytest).
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Behave Modern Report Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,179 @@
1
+ Metadata-Version: 2.4
2
+ Name: behave-modern-html-report
3
+ Version: 1.0.0
4
+ Summary: The modern, beautiful, single-file HTML report formatter for Behave.
5
+ Project-URL: Homepage, https://github.com/MathiasPaulenko/behave-modern-html-report
6
+ Project-URL: Repository, https://github.com/MathiasPaulenko/behave-modern-html-report
7
+ Project-URL: Issues, https://github.com/MathiasPaulenko/behave-modern-html-report/issues
8
+ Author-email: Mathias Paulenko <mathias.paulenko@outlook.com>
9
+ Maintainer-email: Mathias Paulenko <mathias.paulenko@outlook.com>
10
+ License: MIT
11
+ License-File: LICENSE
12
+ Keywords: bdd,behave,formatter,html,report,testing
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Testing :: BDD
20
+ Requires-Python: >=3.11
21
+ Requires-Dist: behave<2,>=1.2.6
22
+ Requires-Dist: jinja2>=3.1
23
+ Provides-Extra: dev
24
+ Requires-Dist: black>=24.0; extra == 'dev'
25
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
26
+ Requires-Dist: pytest>=8.0; extra == 'dev'
27
+ Requires-Dist: ruff>=0.6; extra == 'dev'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # Behave Modern HTML Report
31
+
32
+ > The modern, beautiful, single-file HTML report formatter for [Behave](https://behave.readthedocs.io/).
33
+ > Dark mode, charts, instant search, attachments, zero external requests.
34
+
35
+ [![PyPI](https://img.shields.io/pypi/v/behave-modern-html-report.svg)](https://pypi.org/project/behave-modern-html-report/)
36
+ [![Python](https://img.shields.io/pypi/pyversions/behave-modern-html-report.svg)](https://pypi.org/project/behave-modern-html-report/)
37
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
38
+ [![CI](https://github.com/MathiasPaulenko/behave-modern-html-report/actions/workflows/ci.yml/badge.svg)](https://github.com/MathiasPaulenko/behave-modern-html-report/actions/workflows/ci.yml)
39
+
40
+ `behave-modern-html-report` is a drop-in formatter for Behave that produces a single,
41
+ self-contained HTML file — everything (CSS, JS, fonts, icons, attachments) is
42
+ embedded so the report works offline, on any machine, forever.
43
+
44
+ ## Features
45
+
46
+ - 🌓 **Dark / Light / Auto** themes, modern Material-3 inspired UI
47
+ - 📊 **Interactive charts** (status pie, duration histogram, slowest scenarios, tag pass rate, timeline) — pure vanilla JS, no Chart.js CDN
48
+ - 🏷️ **Tag analytics** page: per-tag counts, pass rate, duration, and a dedicated chart
49
+ - � **Gherkin Rules** support: scenarios under a `Rule` are grouped and tagged correctly (Behave 1.3.x)
50
+ - �🔍 **Instant client-side search** across features, scenarios, steps and tags
51
+ - 🎚️ **Filter by status** with one click
52
+ - 📁 **Expandable** features → scenarios → steps with rich metadata
53
+ - 🧯 **Modern error viewer** with copy-to-clipboard tracebacks
54
+ - 🖼️ **Attachments**: images (with lightbox), JSON, text, binaries
55
+ - 🚀 **Copy-reproduce-command** per scenario (`behave features/example.feature:3`)
56
+ - 📊 **Inline step duration bars** to spot slow steps at a glance
57
+ - ♿ **Accessible**: keyboard navigation, ARIA labels, reduced-motion support
58
+ - 📦 **Single HTML file**, works offline, no web server, no CDN
59
+ - 🧩 **Clean architecture** — formatter / collector / models / renderer separation, fully testable
60
+ - 🛠️ **Extensible** — custom CSS/JS, custom title/logo/company, JSON sidecar, future plugin system
61
+
62
+ ## Installation
63
+
64
+ ```bash
65
+ pip install behave-modern-html-report
66
+ ```
67
+
68
+ ## Quick start
69
+
70
+ In your project's `behave.ini` (or `setup.cfg`):
71
+
72
+ ```ini
73
+ [behave.formatters]
74
+ modern = behave_modern_html_report.formatter:ModernHTMLFormatter
75
+ ```
76
+
77
+ Then run:
78
+
79
+ ```bash
80
+ behave -f modern -o report.html
81
+ ```
82
+
83
+ Open `report.html` in any browser. Done.
84
+
85
+ ## Configuration
86
+
87
+ All options are read from `behave`'s `userdata`:
88
+
89
+ ```ini
90
+ [behave.userdata]
91
+ bmr.title = My Awesome Suite
92
+ bmr.company = Acme Inc.
93
+ bmr.logo = https://example.com/logo.svg
94
+ bmr.theme = auto ; auto | dark | light
95
+ bmr.json_sidecar = true ; writes report.json next to report.html
96
+ bmr.custom_css = path/to/extra.css
97
+ bmr.custom_js = path/to/extra.js
98
+ ```
99
+
100
+ ## Behave 1.3.x and Gherkin Rules compatibility
101
+
102
+ `behave-modern-html-report` is tested against Behave 1.3.x and fully supports the Gherkin `Rule` keyword.
103
+
104
+ - Scenarios under a `Rule` keep their parent rule name and inherit their Rule tags correctly.
105
+ - Extended final statuses (`error`, `hook_error`, `cleanup_error`, `xfailed`, `xpassed`, `pending_warn`) are normalised and displayed in the UI.
106
+ - Error-like statuses are grouped as failures for feature status and tag analytics.
107
+
108
+ ```gherkin
109
+ Feature: Checkout
110
+
111
+ Rule: Payment required
112
+ @payment
113
+ Scenario: Card payment succeeds
114
+ Given the user has items in cart
115
+ When they pay with a valid card
116
+ Then the order is confirmed
117
+ ```
118
+
119
+ ## Attachments from your `environment.py`
120
+
121
+ Use the public helper API — no need to reach into the formatter:
122
+
123
+ ```python
124
+ from behave_modern_html_report import attach_screenshot, attach_text, log
125
+
126
+ def after_step(context, step):
127
+ if step.status == "failed":
128
+ attach_screenshot(context, context.browser, name="failure.png")
129
+ attach_text(context, str(step.exception), name="error.txt")
130
+ log(f"URL at failure: {context.browser.current_url}")
131
+ ```
132
+
133
+ The helpers also work with Playwright, Selenium, PIL images, bytes, files, and JSON data.
134
+
135
+ ## Generate a demo without running Behave
136
+
137
+ ```bash
138
+ python examples/generate_demo.py
139
+ ```
140
+
141
+ This builds `examples/demo-report.html` with a realistic-looking suite —
142
+ useful for previews, screenshots, and design iteration.
143
+
144
+ ## Architecture
145
+
146
+ ```text
147
+ behave events
148
+
149
+
150
+ formatter.py ── thin adapter
151
+
152
+
153
+ collector.py ── builds the model tree
154
+
155
+
156
+ models.py ── pure dataclasses
157
+ (Execution → Feature → Rule-aware Scenario → Step)
158
+
159
+
160
+ statistics.py ── aggregates counters, durations, buckets
161
+
162
+
163
+ renderer.py + templates/ + assets/ ── Jinja2 → single HTML file
164
+ ```
165
+
166
+ The renderer is **independent of Behave**, so any tool that can produce an
167
+ `Execution` object (e.g. a JSON loader) can use it.
168
+
169
+ ## Development
170
+
171
+ ```bash
172
+ pip install -e ".[dev]"
173
+ pytest
174
+ ruff check .
175
+ ```
176
+
177
+ ## License
178
+
179
+ [MIT](LICENSE) © Mathias Paulenko
@@ -0,0 +1,150 @@
1
+ # Behave Modern HTML Report
2
+
3
+ > The modern, beautiful, single-file HTML report formatter for [Behave](https://behave.readthedocs.io/).
4
+ > Dark mode, charts, instant search, attachments, zero external requests.
5
+
6
+ [![PyPI](https://img.shields.io/pypi/v/behave-modern-html-report.svg)](https://pypi.org/project/behave-modern-html-report/)
7
+ [![Python](https://img.shields.io/pypi/pyversions/behave-modern-html-report.svg)](https://pypi.org/project/behave-modern-html-report/)
8
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
9
+ [![CI](https://github.com/MathiasPaulenko/behave-modern-html-report/actions/workflows/ci.yml/badge.svg)](https://github.com/MathiasPaulenko/behave-modern-html-report/actions/workflows/ci.yml)
10
+
11
+ `behave-modern-html-report` is a drop-in formatter for Behave that produces a single,
12
+ self-contained HTML file — everything (CSS, JS, fonts, icons, attachments) is
13
+ embedded so the report works offline, on any machine, forever.
14
+
15
+ ## Features
16
+
17
+ - 🌓 **Dark / Light / Auto** themes, modern Material-3 inspired UI
18
+ - 📊 **Interactive charts** (status pie, duration histogram, slowest scenarios, tag pass rate, timeline) — pure vanilla JS, no Chart.js CDN
19
+ - 🏷️ **Tag analytics** page: per-tag counts, pass rate, duration, and a dedicated chart
20
+ - � **Gherkin Rules** support: scenarios under a `Rule` are grouped and tagged correctly (Behave 1.3.x)
21
+ - �🔍 **Instant client-side search** across features, scenarios, steps and tags
22
+ - 🎚️ **Filter by status** with one click
23
+ - 📁 **Expandable** features → scenarios → steps with rich metadata
24
+ - 🧯 **Modern error viewer** with copy-to-clipboard tracebacks
25
+ - 🖼️ **Attachments**: images (with lightbox), JSON, text, binaries
26
+ - 🚀 **Copy-reproduce-command** per scenario (`behave features/example.feature:3`)
27
+ - 📊 **Inline step duration bars** to spot slow steps at a glance
28
+ - ♿ **Accessible**: keyboard navigation, ARIA labels, reduced-motion support
29
+ - 📦 **Single HTML file**, works offline, no web server, no CDN
30
+ - 🧩 **Clean architecture** — formatter / collector / models / renderer separation, fully testable
31
+ - 🛠️ **Extensible** — custom CSS/JS, custom title/logo/company, JSON sidecar, future plugin system
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ pip install behave-modern-html-report
37
+ ```
38
+
39
+ ## Quick start
40
+
41
+ In your project's `behave.ini` (or `setup.cfg`):
42
+
43
+ ```ini
44
+ [behave.formatters]
45
+ modern = behave_modern_html_report.formatter:ModernHTMLFormatter
46
+ ```
47
+
48
+ Then run:
49
+
50
+ ```bash
51
+ behave -f modern -o report.html
52
+ ```
53
+
54
+ Open `report.html` in any browser. Done.
55
+
56
+ ## Configuration
57
+
58
+ All options are read from `behave`'s `userdata`:
59
+
60
+ ```ini
61
+ [behave.userdata]
62
+ bmr.title = My Awesome Suite
63
+ bmr.company = Acme Inc.
64
+ bmr.logo = https://example.com/logo.svg
65
+ bmr.theme = auto ; auto | dark | light
66
+ bmr.json_sidecar = true ; writes report.json next to report.html
67
+ bmr.custom_css = path/to/extra.css
68
+ bmr.custom_js = path/to/extra.js
69
+ ```
70
+
71
+ ## Behave 1.3.x and Gherkin Rules compatibility
72
+
73
+ `behave-modern-html-report` is tested against Behave 1.3.x and fully supports the Gherkin `Rule` keyword.
74
+
75
+ - Scenarios under a `Rule` keep their parent rule name and inherit their Rule tags correctly.
76
+ - Extended final statuses (`error`, `hook_error`, `cleanup_error`, `xfailed`, `xpassed`, `pending_warn`) are normalised and displayed in the UI.
77
+ - Error-like statuses are grouped as failures for feature status and tag analytics.
78
+
79
+ ```gherkin
80
+ Feature: Checkout
81
+
82
+ Rule: Payment required
83
+ @payment
84
+ Scenario: Card payment succeeds
85
+ Given the user has items in cart
86
+ When they pay with a valid card
87
+ Then the order is confirmed
88
+ ```
89
+
90
+ ## Attachments from your `environment.py`
91
+
92
+ Use the public helper API — no need to reach into the formatter:
93
+
94
+ ```python
95
+ from behave_modern_html_report import attach_screenshot, attach_text, log
96
+
97
+ def after_step(context, step):
98
+ if step.status == "failed":
99
+ attach_screenshot(context, context.browser, name="failure.png")
100
+ attach_text(context, str(step.exception), name="error.txt")
101
+ log(f"URL at failure: {context.browser.current_url}")
102
+ ```
103
+
104
+ The helpers also work with Playwright, Selenium, PIL images, bytes, files, and JSON data.
105
+
106
+ ## Generate a demo without running Behave
107
+
108
+ ```bash
109
+ python examples/generate_demo.py
110
+ ```
111
+
112
+ This builds `examples/demo-report.html` with a realistic-looking suite —
113
+ useful for previews, screenshots, and design iteration.
114
+
115
+ ## Architecture
116
+
117
+ ```text
118
+ behave events
119
+
120
+
121
+ formatter.py ── thin adapter
122
+
123
+
124
+ collector.py ── builds the model tree
125
+
126
+
127
+ models.py ── pure dataclasses
128
+ (Execution → Feature → Rule-aware Scenario → Step)
129
+
130
+
131
+ statistics.py ── aggregates counters, durations, buckets
132
+
133
+
134
+ renderer.py + templates/ + assets/ ── Jinja2 → single HTML file
135
+ ```
136
+
137
+ The renderer is **independent of Behave**, so any tool that can produce an
138
+ `Execution` object (e.g. a JSON loader) can use it.
139
+
140
+ ## Development
141
+
142
+ ```bash
143
+ pip install -e ".[dev]"
144
+ pytest
145
+ ruff check .
146
+ ```
147
+
148
+ ## License
149
+
150
+ [MIT](LICENSE) © Mathias Paulenko
@@ -0,0 +1,42 @@
1
+ """Behave Modern Report.
2
+
3
+ The modern, beautiful, single-file HTML report formatter for Behave.
4
+
5
+ Public API:
6
+ ModernHTMLFormatter -- the Behave entry point.
7
+ Renderer -- standalone renderer (Behave-independent).
8
+ Collector -- builds an execution model from formatter events.
9
+ models -- dataclasses representing the execution tree.
10
+ attach_file -- attach a file to the current step.
11
+ attach_text -- attach a text snippet to the current step.
12
+ attach_json -- attach JSON data to the current step.
13
+ attach_screenshot -- attach a screenshot to the current step.
14
+ log -- append a log line to the current step.
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ from .attach import (
20
+ attach_file,
21
+ attach_json,
22
+ attach_screenshot,
23
+ attach_text,
24
+ log,
25
+ )
26
+ from .collector import Collector
27
+ from .formatter import ModernHTMLFormatter
28
+ from .renderer import Renderer
29
+
30
+ __all__ = [
31
+ "ModernHTMLFormatter",
32
+ "Renderer",
33
+ "Collector",
34
+ "attach_file",
35
+ "attach_text",
36
+ "attach_json",
37
+ "attach_screenshot",
38
+ "log",
39
+ "__version__",
40
+ ]
41
+
42
+ __version__ = "1.0.0"