Metadata-Version: 2.4
Name: pgpro-pytest-html-json-extractor
Version: 1.1.1
Summary: A tool to extract json from pytest-html report
Author-email: Postgres Professional <info@postgrespro.ru>
License-Expression: MIT
Project-URL: HomePage, https://github.com/postgrespro/pgpro-pytest-html-json-extractor
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Framework :: Pytest
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: beautifulsoup4>=4.11.1
Requires-Dist: packaging>=21.0
Dynamic: license-file

[![CI Status](https://img.shields.io/github/actions/workflow/status/postgrespro/pgpro-pytest-html-json-extractor/.github/workflows/ci.yml?label=CI)](https://github.com/postgrespro/pgpro-pytest-html-json-extractor/actions/workflows/ci.yml)
[![PyPI package version](https://badge.fury.io/py/pgpro-pytest-html-json-extractor.svg)](https://badge.fury.io/py/pgpro-pytest-html-json-extractor)
[![PyPI python versions](https://img.shields.io/pypi/pyversions/pgpro-pytest-html-json-extractor)](https://pypi.org/project/pgpro-pytest-html-json-extractor)

# pgpro-pytest-html-json-extractor
A tool to extract json data from pytest-html report. Developed and maintained by Postgres Professional.

## Key features
- Extractor supports pytest-html v4.0.2+
- Extractor produces JSON with unescaped HTML entities in log messages (for pytest-html v4.1.0+)

## Installation
You can install the package directly from the repository (until it's published to PyPI):
```bash
pip install pgpro-pytest-html-json-extractor
```

## Usage

After installation, the tool is available via the pgpro-pytest-html-json-extractor command.

### Basic Examples
Extract JSON from a report:
```bash
pgpro-pytest-html-json-extractor report.html -o report.json
```

### Command Line Arguments

| Argument | Shorthand | Required | Description | Default |
| :--- | :--- | :--- | :--- | :--- |
| `--version` | | No | Show program's version number and exit | None |
| `--out` | `-o` | Yes | Name of the output JSON file | None |
| `--verbose` | `-v` | No | Level of logging verbosity | `3` |
| `--no-check-json` | | No | Do not validate json data after extraction | None |
| `--unescape-logs` | | No | HTML entity decoding mode for logs (`auto`, `yes`, `no`) | `auto` |
| `--replace` | `-r` | No | Replace output if it exists | None |
| `input` | | Yes | Positional argument for HTML file | None |

#### Log Unescaping Modes (--unescape-logs)

The tool provides granular control over how HTML entities (like `&quot;`, `&amp;` or `&#34;`) are handled within test logs:

- **auto (Default)**: Smart detection mode. Automatically decides whether to decode entities based on the detected pytest-html report version. It ensures that logs are restored to their original "human-readable" state while maintaining the safety of other report metadata.

- **yes**: Forceful decoding. Every HTML entity in the log field will be converted back to its literal character. Use this if you are dealing with heavily encoded custom output.

- **no**: Raw mode. Disables all decoding, leaving the log data exactly as it was stored in the HTML source (including "Russian Doll" double-encoding). Ideal for debugging report structure or forensic data analysis.

## Contributing
1. Fork the repository.
2. Create your feature branch (`git checkout -b feature/amazing-feature`).
3. Commit your changes (`git commit -m 'feat: add some amazing feature'`).
4. Push to the branch (`git push origin feature/amazing-feature`).
5. Open a Pull Request.

## License
This project is licensed under the MIT License - see the LICENSE file for details.

© 2026 Postgres Professional
