Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
cf69721
Changelog update
autoreportportal Dec 4, 2024
03cc8f1
Version update
autoreportportal Dec 4, 2024
c53e48d
CHANGELOG.md update
HardNorth Dec 4, 2024
65ab50f
README.rst converted to README.md
HardNorth Dec 5, 2024
c1c7193
Set Python 3.10 as release version of Python
HardNorth Dec 5, 2024
c756aeb
Some type fixes
HardNorth Feb 5, 2025
71fdd7c
Add pytest_bdd check
HardNorth Feb 5, 2025
18c624b
Rollback ubuntu
HardNorth Feb 7, 2025
8648280
Fix typing
HardNorth Feb 7, 2025
a0d080a
Revert "Rollback ubuntu"
HardNorth Feb 7, 2025
42526f9
Update pytest-bdd
HardNorth Feb 7, 2025
77bb9cf
Remove Python 3.7 support
HardNorth Feb 7, 2025
992001a
CHANGELOG.md update
HardNorth Feb 7, 2025
26ba96f
Disable flake8 for specific line
HardNorth Feb 7, 2025
935dc33
Apply new code style
HardNorth Feb 7, 2025
c39e953
Fix typing
HardNorth Feb 7, 2025
d8e8f5e
Fix test
HardNorth Feb 7, 2025
6a4acc8
Disable pydocstyle on examples
HardNorth Feb 7, 2025
303ab98
Client version update
HardNorth Feb 7, 2025
f132256
Fix black config
HardNorth Feb 7, 2025
190dbc2
Bump required version of pytest
HardNorth Feb 7, 2025
f3caa44
Add pytest_bdd example
HardNorth Feb 7, 2025
36fa65c
pytest_bdd: WIP
HardNorth Feb 10, 2025
067286c
pytest_bdd: WIP
HardNorth Feb 10, 2025
ccecf83
Backward compatibility fix
HardNorth Feb 12, 2025
8ac2b14
Update BDD examples
HardNorth Feb 12, 2025
2654b97
Pytest BDD implementation: add item reporting skip
HardNorth Feb 12, 2025
1b557f9
Pytest BDD implementation: fix test
HardNorth Feb 12, 2025
c056d76
Pytest BDD implementation: WIP
HardNorth Feb 12, 2025
93460aa
Pytest BDD implementation: WIP
HardNorth Feb 12, 2025
392f091
Rename PyTestServiceClass to PyTestService
HardNorth Feb 12, 2025
703b4a1
Rename PyTestServiceClass to PyTestService
HardNorth Feb 12, 2025
c2700bf
Do not start item if pytest-bdd detected
HardNorth Feb 12, 2025
7bb0c12
Fix tests
HardNorth Feb 12, 2025
78d353d
Fix imports
HardNorth Feb 12, 2025
86ddb57
Update bdd test
HardNorth Feb 12, 2025
9bab6c5
Pytest BDD implementation: WIP
HardNorth Feb 13, 2025
7518828
Pytest BDD implementation: rollback argument rename and supress some …
HardNorth Feb 13, 2025
add7f61
Pytest BDD implementation: add pydocs and enable checks
HardNorth Feb 13, 2025
4d59e19
Pytest BDD implementation: fix test format
HardNorth Feb 13, 2025
c8cc4a2
Update isort to fix warnings
HardNorth Feb 13, 2025
5c0434c
Add more types
HardNorth Feb 13, 2025
eb3c75d
Pytest BDD implementation: revert Item report skip
HardNorth Feb 13, 2025
c840ed2
Pytest BDD implementation: WIP
HardNorth Feb 13, 2025
9098c3f
Pytest BDD implementation: WIP
HardNorth Feb 13, 2025
3700cc9
Fix fixture failure logging
HardNorth Feb 14, 2025
50a9498
Fix fixture failure logging
HardNorth Feb 14, 2025
76de9b6
Fix fixture failure logging
HardNorth Feb 14, 2025
26580fc
Update test
HardNorth Feb 14, 2025
32f4b9e
Pytest BDD implementation: WIP
HardNorth Feb 14, 2025
0ed5435
Update pre-commit version
HardNorth Feb 15, 2025
404755e
Pytest BDD implementation: WIP
HardNorth Feb 17, 2025
aa0c683
Add code_ref check
HardNorth Feb 18, 2025
8d46179
Add more checks and fixes
HardNorth Feb 18, 2025
97a8b52
Fix traceback logging for old versions of Python
HardNorth Feb 18, 2025
46473fc
Bump pytest-bdd version
HardNorth Feb 18, 2025
bdc6423
Bump pytest-bdd version
HardNorth Feb 18, 2025
eaf449e
Backward compatibility fixes
HardNorth Feb 18, 2025
48ef88c
Backward compatibility fixes
HardNorth Feb 18, 2025
6ec27d3
Add tests
HardNorth Feb 18, 2025
be1e978
Add tests
HardNorth Feb 18, 2025
ea9d056
Fix `report_bdd_step_error` function
HardNorth Feb 18, 2025
93c6762
Make docstring test separate one
HardNorth Feb 18, 2025
428ea22
Backward compatibility fix
HardNorth Feb 18, 2025
0b3d9da
Add another test and fixes
HardNorth Feb 18, 2025
9f620a2
Add another check and fixes
HardNorth Feb 18, 2025
d6cedd4
Log pytest's error to scenario
HardNorth Feb 19, 2025
a61490a
A style fix
HardNorth Feb 19, 2025
b465f2d
Rename test
HardNorth Feb 19, 2025
7592988
Add more tests
HardNorth Feb 19, 2025
a444a78
Add attribute processing
HardNorth Feb 19, 2025
196e9f0
Add another test
HardNorth Feb 19, 2025
ef2ae98
Add another test
HardNorth Feb 19, 2025
ec4ff64
Pytest BDD implementation: Backgrounds: WIP
HardNorth Feb 20, 2025
f958ef1
Pytest BDD implementation: finish Backgrounds
HardNorth Feb 20, 2025
6117895
Fix item merge
HardNorth Feb 21, 2025
bee4fd2
Fix item merge
HardNorth Feb 21, 2025
e0d2d2a
Unignore tests
HardNorth Feb 21, 2025
9eec76a
Add another test
HardNorth Feb 21, 2025
bacf9fd
Pytest BDD implementation: Rule keyword: WIP
HardNorth Feb 21, 2025
5b2d650
Pytest BDD implementation: Rule keyword: WIP
HardNorth Feb 21, 2025
f4b9c96
Fix tests
HardNorth Feb 24, 2025
e46ca72
Add more tests
HardNorth Feb 24, 2025
3cddf89
Pytest BDD implementation: Scenario Outline: WIP
HardNorth Feb 24, 2025
5407563
Pytest BDD implementation: Scenario Outline: done
HardNorth Feb 25, 2025
8450e9f
Fix tests for Python 3.8
HardNorth Feb 25, 2025
37db7a8
Fix tests for Python 3.8
HardNorth Feb 25, 2025
d8f2f37
Fix tests for Python 3.8
HardNorth Feb 25, 2025
ab276fe
Fix isort
HardNorth Feb 25, 2025
36ca80c
Update reportportal-client to 5.6.1 and refactor scenario description…
HardNorth Feb 26, 2025
b651424
Fix isort
HardNorth Feb 26, 2025
6b61ea4
Add more tests
HardNorth Feb 26, 2025
b427f45
Backward compatibility fixes
HardNorth Feb 26, 2025
86562a1
Fix parameter description
HardNorth Feb 27, 2025
729aa0f
Simplify parameter get
HardNorth Feb 27, 2025
c2e660b
Add dynamic name test and fixes
HardNorth Feb 27, 2025
27b04b0
Add another test
HardNorth Feb 27, 2025
11da029
Add more tests
HardNorth Feb 27, 2025
4f4bbc2
Fix fixture reporting
HardNorth Feb 27, 2025
973ab30
Disable some test for old version of pytest_bdd
HardNorth Feb 27, 2025
928617e
Fix imports
HardNorth Feb 27, 2025
23d21a9
Small refactoring
HardNorth Feb 27, 2025
67b8e57
Add custom Test Case ID
HardNorth Feb 28, 2025
35170f3
Add run with no pytest-bdd
HardNorth Feb 28, 2025
3d6c9d0
Remove cov from nobdd
HardNorth Feb 28, 2025
0fc4d77
Remove cov from nobdd
HardNorth Feb 28, 2025
2daf3aa
Remove cov from nobdd
HardNorth Feb 28, 2025
986030a
Fixes #389
HardNorth Feb 28, 2025
269f21b
Fixes #390
HardNorth Feb 28, 2025
db10812
Fixes for Python 3.8
HardNorth Feb 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on:
paths-ignore:
- '.github/**'
- CHANGELOG.md
- README.rst
- README.md
- CONTRIBUTING.rst

env:
Expand All @@ -41,7 +41,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.8'
python-version: '3.10'

- name: Install dependencies
run: python -m pip install --upgrade pip setuptools wheel
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13' ]
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12', '3.13' ]
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
43 changes: 24 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/PyCQA/pydocstyle
rev: 6.0.0
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/PyCQA/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
- id: pydocstyle
exclude: |
(?x)^(
tests/.* |
examples/.*
)
- repo: https://github.com/Lucas-C/pre-commit-hooks-markup
rev: v1.0.1
(?x)^(
tests/.* |
examples/.*
)
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
args: [ '--check', 'pytest_reportportal', 'tests' ]
- repo: https://github.com/pycqa/isort
rev: 6.0.0
hooks:
- id: rst-linter
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 7.1.1
hooks:
- id: flake8
- id: flake8
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# Changelog

## [Unreleased]
### Removed
- `Python 3.7` support, by @HardNorth

## [5.4.7]
### Added
- Escaping of binary symbol '\0' in parameters, by @HardNorth
- Issue [#382](https://github.com/reportportal/agent-python-pytest/issues/382): Escaping of binary symbol '\0' in parameters, by @HardNorth
### Changed
- Client version updated on [5.6.0](https://github.com/reportportal/client-Python/releases/tag/5.6.0), by @HardNorth

## [5.4.6]
### Added
Expand Down
122 changes: 122 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# ReportPortal integration for pytest framework

Pytest plugin for reporting test results of the Pytest to the ReportPortal.

> **DISCLAIMER**: We use Google Analytics for sending anonymous usage information such as agent's and client's names,
> and their versions after a successful launch start. This information might help us to improve both ReportPortal
> backend and client sides. It is used by the ReportPortal team only and is not supposed for sharing with 3rd parties.

[![PyPI](https://img.shields.io/pypi/v/pytest-reportportal.svg?maxAge=259200)](https://pypi.python.org/pypi/pytest-reportportal)
[![Python versions](https://img.shields.io/pypi/pyversions/pytest-reportportal.svg)](https://pypi.org/project/pytest-reportportal)
[![Tests](https://github.com/reportportal/agent-python-pytest/actions/workflows/tests.yml/badge.svg)](https://github.com/reportportal/agent-python-pytest/actions/workflows/tests.yml)
[![codecov](https://codecov.io/gh/reportportal/agent-python-pytest/graph/badge.svg?token=x5ZHqZKJFV)](https://codecov.io/gh/reportportal/agent-python-pytest)
[![Join Slack chat!](https://img.shields.io/badge/slack-join-brightgreen.svg)](https://slack.epmrpp.reportportal.io/)
[![stackoverflow](https://img.shields.io/badge/reportportal-stackoverflow-orange.svg?style=flat)](http://stackoverflow.com/questions/tagged/reportportal)
[![Build with Love](https://img.shields.io/badge/build%20with-❤%EF%B8%8F%E2%80%8D-lightgrey.svg)](http://reportportal.io?style=flat)

## Installation

To install pytest plugin execute next command in a terminal:

```bash
pip install pytest-reportportal
```

Look through the `CONTRIBUTING.rst` for contribution guidelines.

## Configuration

Prepare the config file `pytest.ini` in root directory of tests or specify any one using pytest command line option:

```bash
py.test -c config.cfg
```

The `pytest.ini` file should have next mandatory fields:

- `rp_api_key` - value could be found in the User Profile section
- `rp_project` - name of project in ReportPortal
- `rp_endpoint` - address of ReportPortal Server

Example of `pytest.ini`:

```text
[pytest]
rp_api_key = fb586627-32be-47dd-93c1-678873458a5f
rp_endpoint = http://192.168.1.10:8080
rp_project = user_personal
rp_launch = AnyLaunchName
rp_launch_attributes = 'PyTest' 'Smoke'
rp_launch_description = 'Smoke test'
rp_ignore_attributes = 'xfail' 'usefixture'
```

- The `rp_api_key` can also be set with the environment variable `RP_API_KEY`. This will override the value set for `rp_api_key` in pytest.ini

There are also optional parameters:
https://reportportal.io/docs/log-data-in-reportportal/test-framework-integration/Python/pytest/

## Examples

For logging of the test item flow to ReportPortal, please, use the python logging handler provided by plugin like
below:

in `conftest.py`:

```python
import logging

import pytest

from reportportal_client import RPLogger


@pytest.fixture(scope="session")
def rp_logger():
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logging.setLoggerClass(RPLogger)
return logger
```

in tests:

```python
# In this case only INFO messages will be sent to the ReportPortal.
def test_one(rp_logger):
rp_logger.info("Case1. Step1")
x = "this"
rp_logger.info("x is: %s", x)
assert 'h' in x

# Message with an attachment.
import subprocess
free_memory = subprocess.check_output("free -h".split())
rp_logger.info(
"Case1. Memory consumption",
attachment={
"name": "free_memory.txt",
"data": free_memory,
"mime": "application/octet-stream",
},
)

# This debug message will not be sent to the ReportPortal.
rp_logger.debug("Case1. Debug message")
```

## Launching

To run test with ReportPortal you must provide `--reportportal` flag:

```bash
py.test ./tests --reportportal
```

Check the documentation to find more detailed information about how to integrate pytest with ReportPortal using the
agent:
https://reportportal.io/docs/log-data-in-reportportal/test-framework-integration/Python/pytest/

## Copyright Notice

Licensed under the [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0) license (see the LICENSE file).
141 changes: 0 additions & 141 deletions README.rst

This file was deleted.

4 changes: 1 addition & 3 deletions examples/attributes/test_runtime_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@ def test_custom_attributes_report(request):
This is a test with one custom marker as a decorator and one custom marker
added at runtime which shall both appear on ReportPortal on test's item
"""
request.node.add_marker(
pytest.mark.runtime()
)
request.node.add_marker(pytest.mark.runtime())
assert True
8 changes: 8 additions & 0 deletions examples/bdd/features/arguments_four_steps.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Feature: Four step arguments
Scenario: Arguments for given, when, and, then
Given there are 5 cucumbers

When I eat 3 cucumbers
And I eat 2 cucumbers

Then I should have 0 cucumbers
11 changes: 11 additions & 0 deletions examples/bdd/features/arguments_four_steps_description.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Feature: Four step arguments
Description for the feature

Scenario: Arguments for given, when, and, then
Description for the scenario

Given there are 5 cucumbers
When I eat 3 cucumbers
And I eat 2 cucumbers

Then I should have 0 cucumbers
Loading