FiscalFixtures BR
Brazilian Fiscal Documents Testing Toolkit
Leia em Português: README.pt-BR.md
FiscalFixtures BR is an open-source Python toolkit providing fictional Brazilian electronic fiscal XML documents, reusable test fixtures, deterministic NF-e generation utilities, secure XML validation, and automated testing scenarios.
Important Notice — Test Data Only: All XML fixtures and generated documents use 100% fictional data and homologation (
tpAmb=2) markers. They are not officially authorized by SEFAZ and must never be used for production fiscal issuance.
Why FiscalFixtures BR?
Developers building ERPs, accounting software, e-commerce checkouts, and fiscal integrations in Brazil spend significant time crafting XML payloads and reproducing edge cases (malformed XML, missing tags, invalid numeric types, Simples Nacional vs. Normal regime, freight/discounts).
FiscalFixtures BR solves this by offering:
- Curated Fictional XML Fixtures: Ready-to-use valid and intentionally invalid NF-e 4.00 XMLs.
- Numeric & Alphanumeric CNPJ Support: Validates and generates both traditional numeric CNPJs and July 2026 alphanumeric CNPJs (
[A-Z0-9]{12}[0-9]{2}, Receita Federal ASCII-48 mod-11, e.g.00.000.000/E08G-12). - Deterministic NF-e Generator: Generate customizable NF-e 4.00 XMLs with
seedsupport for reproducible tests. - Secure Multi-Stage XML Validator: Distinguishes well-formedness, NF-e structural rules, and optional local XSD validation with XXE/DTD protection enabled by default.
- Reusable Testing Scenarios: Standardized scenarios (
valid_xml,malformed_xml,missing_required_field,invalid_numeric_value,missing_namespace,xxe_payload, etc.). - Clean CLI (
fiscalfixtures): Inspect fixtures, generate test XMLs, and validate files from the terminal.
Supported Document Types
| Document | Status | Notes |
|---|---|---|
| NF-e (Modelo 55, Layout 4.00) | Supported (v0.1.0) |
Fixtures, generator, structural validator |
| NFC-e (Modelo 65) | Planned (v0.5.0) |
Directory structure prepared |
| CT-e (Modelo 57) | Planned (Future) | Directory structure prepared |
| MDF-e (Modelo 58) | Planned (Future) | Roadmap item |
Installation
Install from GitHub (pre-PyPI release):
pip install git+https://github.com/moisesz10/FISCALFIXTURES-BR.git
Note: PyPI publication (
pip install fiscalfixtures-br) is planned for the first public release (v0.1.0/v1.0.0).
For local development with uv:
git clone https://github.com/moisesz10/FISCALFIXTURES-BR.git
cd FISCALFIXTURES-BR
uv sync --all-extras
Quick Start
1. Load a Curated Fixture
from fiscalfixtures.fixtures import load_fixture, get_fixture_metadata
xml = load_fixture("nfe/basic")
meta = get_fixture_metadata("nfe/basic")
print(meta.document_type, meta.layout_version)
2. Validate an XML Document
from fiscalfixtures.validators import validate_xml
result = validate_xml("examples/nfe/basic.xml")
print(result.is_valid) # True
print(result.validation_stage) # "completed"
print(result.errors) # []
3. Generate a Fictional NF-e XML
from fiscalfixtures.generators import NFeGenerator
generator = NFeGenerator(seed=42)
xml = generator.generate(scenario="multiple_products", products=3)
CLI Usage
# List available fixtures
fiscalfixtures list
# Show fixture metadata
fiscalfixtures info nfe/basic
# Generate a deterministic fictional NF-e XML
fiscalfixtures generate nfe --scenario basic --seed 42 --output sample.xml
# Validate an XML file (optionally with a local verified XSD)
fiscalfixtures validate sample.xml
fiscalfixtures validate sample.xml --xsd path/to/nfe_v4.00.xsd
# List reusable testing scenarios
fiscalfixtures scenarios
# Check supported schema versions and local XSD availability
fiscalfixtures schemas
# Show installed version
fiscalfixtures version
Project Structure
FiscalFixtures-BR/
├── src/fiscalfixtures/
│ ├── cli/ # Typer CLI commands
│ ├── data/fixtures/ # Packaged fictional XML fixtures & manifest
│ ├── fixtures/ # Secure fixture loader
│ ├── generators/ # Deterministic NF-e 4.00 generator
│ ├── models/ # Pydantic v2 domain models
│ ├── scenarios/ # Reusable testing scenarios catalog
│ └── validators/ # Multi-stage secure XML & XSD validators
├── examples/ # Browsable valid XML examples
├── invalid-examples/ # Browsable invalid XML examples
├── schemas/ # Instructions for local official XSD usage
├── docs/ # MkDocs documentation
├── tests/ # Unit and integration tests
└── .github/ # CI workflows and issue/PR templates
Running Tests & Quality Checks
uv run pytest --cov=fiscalfixtures --cov-report=term-missing
uv run ruff check src tests
uv run mypy src tests
Security
FiscalFixtures BR is designed with strict security defaults:
- XXE & DTD Protection: External entities, DTD loading, and network access are disabled in
lxml.<!DOCTYPEand<!ENTITYdeclarations are explicitly rejected. - Path Traversal Prevention: Fixture IDs are validated against a strict allowlist regex and resolved paths are verified to stay within the packaged fixtures directory.
- No Real Fiscal Data: Never commit real NF-e XMLs, real CNPJs/CPFs of customers, or digital certificates (
.pfx/.p12).
See SECURITY.md for responsible vulnerability reporting.
Roadmap
- v0.1.0 — Foundation: Core Python package, NF-e 4.00 fixtures, loader, deterministic generator, secure XML validator, CLI, tests, and docs.
- v0.2.0 — Developer Toolkit: Expanded NF-e scenarios, richer tax/item customization, enhanced validation diagnostics.
- v0.3.0 — Validation: Verified official XSD integration guides and extended structural checks.
- v0.4.0 — Community: Expanded contributor-submitted fixtures and scenarios.
- v0.5.0 — Expansion: NFC-e (Modelo 65) support.
- Future: CT-e, MDF-e, optional FastAPI integration.
Contributing
Contributions are warmly welcome! Please read CONTRIBUTING.md and our CODE_OF_CONDUCT.md before submitting a pull request.
License
Licensed under the MIT License.
Metadata
Release files for fiscalfixtures-br 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fiscalfixtures_br-0.1.0.tar.gz | 58.5 kB | With provenance | Details for fiscalfixtures_br-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fiscalfixtures_br-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for fiscalfixtures_br-0.1.0-py3-none-any.whl |
Total release size: 108.8 kB
Release files / fiscalfixtures_br-0.1.0.tar.gz
| Download URL | fiscalfixtures_br-0.1.0.tar.gz |
|---|---|
| Size | 58.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f59c3af696bd1a085eb301213d8574855ac9d22385734e7864aa2b79b1d2b1f2
|
|
BLAKE2b-256 checksum How to use checksums |
6cfb8ce8bcdc3fbd8c9868e94028e735b8e1a4df979749415c3c964733a52a36
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logRelease files / fiscalfixtures_br-0.1.0-py3-none-any.whl
| Download URL | fiscalfixtures_br-0.1.0-py3-none-any.whl |
|---|---|
| Size | 50.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ccd562cf8592a7117c2983d5f3499395886f7099e04f16f3af9fc99aca6daa84
|
|
BLAKE2b-256 checksum How to use checksums |
95596e9c7d3cfab713d5a606d07be7832810405894935cdd582942d7e18c02ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logSecurity for fiscalfixtures-br 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for fiscalfixtures_br-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.