Skip to content

Configuration

Configuration PyTest


For configuration pytest package we use pytest.ini.

Many pytest settings can be set in a configuration file, which by convention resides in the root directory of your repository.

Here we registrate pytest.marks for our tests.

Fixtures


Pytest fixtures provides in conftest.py.

This module provides a fixture for pytest.

User

Class User for test API.

Source code in QA-framework/conftest.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
class User:
    """Class User for test API."""
    def __init__(self) -> None:
        self.name = None
        self.second_name = None

    def create(self):
        """Create user properties."""
        self.name = 'Oleksandr'
        self.second_name = 'Khomenko'

    def remove(self):
        """Clean user properties."""
        self.name = ''
        self.second_name = ''

create()

Create user properties.

Source code in QA-framework/conftest.py
13
14
15
16
def create(self):
    """Create user properties."""
    self.name = 'Oleksandr'
    self.second_name = 'Khomenko'

remove()

Clean user properties.

Source code in QA-framework/conftest.py
18
19
20
21
def remove(self):
    """Clean user properties."""
    self.name = ''
    self.second_name = ''

General configuration


In cofig.yaml file we define several settings:

  • API URLs
  • Database path
  • UI driver path

Then in config.py reads the config file & saves it to dictionary.