pytest-jira
raw JSON → 0.3.24 verified Fri May 01 auth: no python
pytest plugin for JIRA integration using markers. Allows linking test cases to JIRA issues, updating test results, and verifying issue status. Current version 0.3.24, requires Python >=3.9. Maintained irregularly with community contributions.
pip install pytest-jira Common errors
error ModuleNotFoundError: No module named 'pytest_jira' ↓
cause pytest-jira not installed or not in Python environment.
fix
Run 'pip install pytest-jira' in the correct environment.
error AttributeError: module 'pytest' has no attribute 'mark' ↓
cause Missing pytest import or pytest version incompatibility.
fix
Ensure 'import pytest' is at top of test file and pytest is installed.
error pytest_jira.plugin.PytestJiraError: JIRA URL not set. Set JIRA_URL environment variable or in pytest.ini ↓
cause Required environment variables not configured.
fix
Set JIRA_URL (and JIRA_USER/JIRA_PASSWORD or JIRA_TOKEN) in environment or pytest.ini.
Warnings
gotcha Plugin auto-registers; do not import pytest_jira directly in test files. Instead, use the marker @pytest.mark.jira('KEY') after installing the package. ↓
fix Remove any explicit import of pytest_jira. The plugin is activated by installing the package.
deprecated Using 'py.test' command is deprecated; use 'pytest' instead. ↓
fix Run tests with 'pytest' not 'py.test'.
breaking From version 0.3.19, token authentication via JIRA_TOKEN environment variable is supported. In previous versions only basic auth (username/password) was available. ↓
fix Set JIRA_TOKEN environment variable instead of JIRA_USER/JIRA_PASSWORD if using token auth.
gotcha Connectivity check may fail with invalid JSON if JIRA response is not expected format; fixed in 0.3.23. ↓
fix Upgrade to >=0.3.23 to avoid JSON parsing errors during connectivity check.
Imports
- pytest_jira wrong
import pytest_jiracorrectpytest_plugins = ['pytest_jira']
Quickstart
import os
# Configure via environment variables (recommended) or pytest.ini
os.environ['JIRA_URL'] = 'https://your-jira-instance.atlassian.net'
os.environ['JIRA_USER'] = 'your-email@example.com'
os.environ['JIRA_PASSWORD'] = os.environ.get('JIRA_PASSWORD', '')
# Or use token authentication:
# os.environ['JIRA_TOKEN'] = 'your-api-token'
# Mark test with JIRA issue key
import pytest
@pytest.mark.jira('PROJECT-123')
def test_example():
assert 1 + 1 == 2