Flake8 JUnit Report Basic

3.0.0 · active · verified Sat Apr 11

flake8-junit-report-basic is a simple Python command-line tool (version 3.0.0) that converts the output from Flake8 static analysis into the JUnit XML format. This conversion facilitates integration with Continuous Integration (CI) systems like Jenkins or CircleCI, allowing them to display Flake8 failures alongside other test results. The project shows recent activity with its 3.0.0 release, though its historical context includes an older, unmaintained fork.

Warnings

Install

Quickstart

The quickstart demonstrates how to use `flake8-junit-report-basic` by first running `flake8` to generate a text report, and then using the `flake8_junit` command-line utility to convert that report into a JUnit XML file. This JUnit XML file can then be consumed by CI/CD tools. Ensure `flake8` is installed and a `my_module.py` file with some Flake8 issues is present for a meaningful report.

# 1. Create a dummy Python file with a Flake8 error
Path('my_module.py').write_text('import os; x = 1  ') # E222, W292

# 2. Run Flake8 and save its output to a file
# This simulates the output that flake8_junit expects
result = subprocess.run(
    ['flake8', '--output-file', 'flake8_report.txt', 'my_module.py'],
    capture_output=True, text=True
)

# 3. Convert the Flake8 output file to JUnit XML format
# The executable is named 'flake8_junit'
junit_result = subprocess.run(
    ['flake8_junit', 'flake8_report.txt', 'junit_report.xml'],
    capture_output=True, text=True
)

# Optional: Print the generated JUnit XML content
print(Path('junit_report.xml').read_text())

view raw JSON →