Metadata-Version: 2.1
Name: pytest-zebrunner
Version: 0.1.0
Summary: Pytest connector for Zebrunner reporting
Home-page: https://zebrunner.com/documentation/agents/pytest
License: Apache
Keywords: automation,zebrunner,testing
Author: Anatoliy Platonov
Author-email: p4m.dev@gmail.com
Requires-Python: >=3.7,<4.0
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: Apache Software License
Classifier: License :: Other/Proprietary License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Internet
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: httpx (>=0.16.1,<0.17.0)
Requires-Dist: pydantic (>=1.7.2,<2.0.0)
Requires-Dist: pytest (>=6.1.1,<7.0.0)
Requires-Dist: python-dotenv (>=0.15.0,<0.16.0)
Project-URL: Repository, https://github.com/zebrunner/python-agent-pytest
Description-Content-Type: text/markdown

# Zebrunner PyTest agent


The official Zebrunner Pytest agent provides reporting functionality. It can automatically track selenium sessions
and send info about session details to Zebrunner backend. It can be ease integrated in project just by installing library
and adding configuration file.


## Installation
---------------

    pip install pytest-zebrunner

## Configuration
----------------
Library don't ready for usage just after installation. It won't send data to
zebrunner service without additional configuration. To configure app you need to
specify environment variables. It can be done by specifying variables in `.env`
file.

<!-- groups:start -->
### Environment variables
```dosini
SERVICE_URL=<zebrunner url>
ACCESS_TOKEN=<access_token>
ZEBRUNNER_PROJECT=ProjectName
ZEBRUNNER_ENABLED=true
BUILD=1.25.16
ENV=stage
```

You can configure agent only with environment variables. Another formats would
be added in future. Planed formats are `yaml`, `ini` and program arguments.

- `SERVICE_URL` - [required] Base URL of Zebrunner service.

- `ACCESS_TOKEN` - [required] Authorization token. You can find it in Account & profile section.

- `ZEBRUNNER_PROJECT` - [required] Name of project.

- `REPORTING_ENABLED` - You can disable agent if it makes side effects in you project or doesn't work.

- `BUILD` - Version of product on which tests are running.

- `ENV` - Testing environment name.
<!-- groups:end -->

If required configurations not provided there is a warning in logs with problem description and names of options,
which need to be specified. Parameter names are case insensitive and can be written in upper and lower registers.

## Additional functionality
---------------------------
**IMPORTANT**: All attachments to tests can be done only while some test is running. All attachments to test-run can be done only while pytest test-session is active.
---------------------------


### Attach screenshot
```python
from pytest_zebrunner.attachments import attach_test_screenshot


def test_something():
    ...
    attach_test_screenshot("path_to_screenshot.png")
    ...
```

### Attach artifact to test
```python
from pytest_zebrunner.attachments import attach_test_artifact


def test_something():
    ...
    attach_test_artifact("path_to_artifact")
    ...
```

### Attach artifact-reference to test
```python
from pytest_zebrunner.attachments import attach_test_artifact_reference


def test_something():
    ...
    attach_test_artifact_reference("name", "reference")
    ...
```

### Attach artifact to test-run
```python
from pytest_zebrunner.attachments import attach_test_run_artifact


attach_test_run_artifact("path_to_artifact")
```

### Attach artifact-reference to test-run
```python
from pytest_zebrunner.attachments import attach_test_run_artifact_reference


attach_test_run_artifact_reference("name", "reference")
```

### Attach labels to test
```python
@pytest.mark.label("name", "value")
def test_something():
    ...
```
or
```python
from pytest_zebrunner.attachments import attach_test_label


def test_something():
    ...
    attach_test_label("name", "value")
    ...
```
**Note:** These two methods can be combined.

### Attach label to test run
```python
from pytest_zebrunner.attachments import attach_test_run_label

attach_test_run_label("name", "value")
```

### Add maintainer to test
```python
@pytest.mark.maintainer("username_of_maintainer")
def test_something():
    ...
```

