A pytest plugin, that enables you to test your code that relies on a running PostgreSQL Database

Overview

https://raw.githubusercontent.com/ClearcodeHQ/pytest-postgresql/master/logo.png

pytest-postgresql

Latest PyPI version Wheel Status Supported Python Versions License

What is this?

This is a pytest plugin, that enables you to test your code that relies on a running PostgreSQL Database. It allows you to specify fixtures for PostgreSQL process and client.

How to use

Warning

Tested on PostgreSQL versions >= 10. See tests for more details.

Install with:

pip install pytest-postgresql

You will also need to install psycopg. See its installation instructions.

Plugin contains three fixtures:

  • postgresql - it's a client fixture that has functional scope. After each test it ends all leftover connections, and drops test database from PostgreSQL ensuring repeatability. This fixture returns already connected psycopg connection.
  • postgresql_proc - session scoped fixture, that starts PostgreSQL instance at it's first use and stops at the end of the tests.
  • postgresql_noproc - a noprocess fixture, that's connecting to already running postgresql instance. For example on dockerized test environments, or CI providing postgresql services

Simply include one of these fixtures into your tests fixture list.

You can also create additional postgresql client and process fixtures if you'd need to:

from pytest_postgresql import factories

postgresql_my_proc = factories.postgresql_proc(
    port=None, unixsocketdir='/var/run')
postgresql_my = factories.postgresql('postgresql_my_proc')

Note

Each PostgreSQL process fixture can be configured in a different way than the others through the fixture factory arguments.

Sample test

def test_example_postgres(postgresql):
    """Check main postgresql fixture."""
    cur = postgresql.cursor()
    cur.execute("CREATE TABLE test (id serial PRIMARY KEY, num integer, data varchar);")
    postgresql.commit()
    cur.close()

If you want the database fixture to be automatically populated with your schema there are two ways:

  1. client fixture specific
  2. process fixture specific

Both are accepting same set of possible loaders:

  • sql file path
  • loading function import path (string)
  • actual loading function

That function will receive host, port, user, dbname and password kwargs and will have to perform connection to the database inside. However, you'll be able to run SQL files or even trigger programmatically database migrations you have.

Client specific loads the database each test

postgresql_my_with_schema = factories.postgresql(
    'postgresql_my_proc',
    load=["schemafile.sql", "otherschema.sql", "import.path.to.function", "import.path.to:otherfunction", load_this]
)

Warning

This way, the database will still be dropped each time.

The process fixture performs the load once per test session, and loads the data into the template database. Client fixture then creates test database out of the template database each test, which significantly speeds up the tests.

postgresql_my_proc = factories.postgresql_proc(
    load=["schemafile.sql", "otherschema.sql", "import.path.to.function", "import.path.to:otherfunction", load_this]
)
pytest --postgresql-populate-template=path.to.loading_function --postgresql-populate-template=path.to.other:loading_function --postgresql-populate-template=path/to/file.sql

The loading_function from example will receive , and have to commit that. Connecting to already existing postgresql database --------------------------------------------------

Some projects are using already running postgresql servers (ie on docker instances). In order to connect to them, one would be using the postgresql_noproc fixture.

postgresql_external = factories.postgresql('postgresql_noproc')

By default the postgresql_noproc fixture would connect to postgresql instance using 5432 port. Standard configuration options apply to it.

These are the configuration options that are working on all levels with the postgresql_noproc fixture:

Configuration

You can define your settings in three ways, it's fixture factory argument, command line option and pytest.ini configuration option. You can pick which you prefer, but remember that these settings are handled in the following order:

  • Fixture factory argument
  • Command line option
  • Configuration option in your pytest.ini file
Configuration options
PostgreSQL option Fixture factory argument Command line option pytest.ini option Noop process fixture Default
Path to executable executable --postgresql-exec postgresql_exec
/usr/lib/postgresql/13/bin/pg_ctl
host host --postgresql-host postgresql_host yes 127.0.0.1
port port --postgresql-port postgresql_port yes (5432) random
postgresql user user --postgresql-user postgresql_user yes postgres
password password --postgresql-password postgresql_password yes  
Starting parameters (extra pg_ctl arguments) startparams --postgresql-startparams postgresql_startparams
-w
Postgres exe extra arguments (passed via pg_ctl's -o argument) postgres_options --postgresql-postgres-options postgresql_postgres_options
 
Log filename's prefix logsprefix --postgresql-logsprefix postgresql_logsprefix
 
Location for unixsockets unixsocket --postgresql-unixsocketdir postgresql_unixsocketdir
$TMPDIR
Database name dbname --postgresql-dbname postgresql_dbname yes, however with xdist an index is being added to name, resulting in test0, test1 for each worker. test
Default Schema either in sql files or import path to function that will load it (list of values for each) load --postgresql-load postgresql_load yes  
PostgreSQL connection options options --postgresql-options postgresql_options yes  

Example usage:

  • pass it as an argument in your own fixture

    postgresql_proc = factories.postgresql_proc(
        port=8888)
  • use --postgresql-port command line option when you run your tests

    py.test tests --postgresql-port=8888
    
  • specify your port as postgresql_port in your pytest.ini file.

    To do so, put a line like the following under the [pytest] section of your pytest.ini:

    [pytest]
    postgresql_port = 8888

Examples

Populating database for tests

With SQLAlchemy

This example shows how to populate database and create an SQLAlchemy's ORM connection:

Sample below is simplified session fixture from pyramid_fullauth tests:

from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.pool import NullPool
from zope.sqlalchemy import register


@pytest.fixture
def db_session(postgresql):
    """Session for SQLAlchemy."""
    from pyramid_fullauth.models import Base

    connection = f'postgresql+psycopg2://{postgresql.info.user}:@{postgresql.info.host}:{postgresql.info.port}/{postgresql.info.dbname}'

    engine = create_engine(connection, echo=False, poolclass=NullPool)
    pyramid_basemodel.Session = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
    pyramid_basemodel.bind_engine(
        engine, pyramid_basemodel.Session, should_create=True, should_drop=True)

    yield pyramid_basemodel.Session

    transaction.commit()
    Base.metadata.drop_all(engine)


@pytest.fixture
def user(db_session):
    """Test user fixture."""
    from pyramid_fullauth.models import User
    from tests.tools import DEFAULT_USER

    new_user = User(**DEFAULT_USER)
    db_session.add(new_user)
    transaction.commit()
    return new_user


def test_remove_last_admin(db_session, user):
    """
    Sample test checks internal login, but shows usage in tests with SQLAlchemy
    """
    user = db_session.merge(user)
    user.is_admin = True
    transaction.commit()
    user = db_session.merge(user)

    with pytest.raises(AttributeError):
        user.is_admin = False

Note

See the original code at pyramid_fullauth's conftest file. Depending on your needs, that in between code can fire alembic migrations in case of sqlalchemy stack or any other code

Maintaining database state outside of the fixtures

It is possible and appears it's used in other libraries for tests, to maintain database state with the use of the pytest-postgresql database managing functionality:

For this import DatabaseJanitor and use its init and drop methods:

import pytest
from pytest_postgresql.janitor import DatabaseJanitor

@pytest.fixture
def database(postgresql_proc):
    # variable definition

    janitor = DatabaseJanitor(
        postgresql_proc.user,
        postgresql_proc.host,
        postgresql_proc.port,
        "my_test_database",
        postgresql_proc.version,
        password="secret_password,
    ):
    janitor.init()
    yield psycopg2.connect(
        dbname="my_test_database",
        user=postgresql_proc.user,
        password="secret_password",
        host=postgresql_proc.host,
        port=postgresql_proc.port,
    )
    janitor.drop()

or use it as a context manager:

import pytest
from pytest_postgresql.janitor import DatabaseJanitor

@pytest.fixture
def database(postgresql_proc):
    # variable definition

    with DatabaseJanitor(
        postgresql_proc.user,
        postgresql_proc.host,
        postgresql_proc.port,
        "my_test_database",
        postgresql_proc.version,
        password="secret_password,
    ):
        yield psycopg2.connect(
            dbname="my_test_database",
            user=postgresql_proc.user,
            password="secret_password",
            host=postgresql_proc.host,
            port=postgresql_proc.port,
        )

Note

DatabaseJanitor manages the state of the database, but you'll have to create connection to use in test code yourself.

You can optionally pass in a recognized postgresql ISOLATION_LEVEL for additional control.

Note

See DatabaseJanitor usage in python's warehouse test code https://github.com/pypa/warehouse/blob/5d15bfe/tests/conftest.py#L127

Connecting to Postgresql (in a docker)

To connect to a docker run postgresql and run test on it, use noproc fixtures.

docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres

This will start postgresql in a docker container, however using a postgresql installed locally is not much different.

In tests, make sure that all your tests are using postgresql_noproc fixture like that:

postgresql_in_docker = factories.postgresql_noproc()
postresql = factories.postgresql("postgresql_in_docker", db_name="test")


def test_postgres_docker(postresql):
    """Run test."""
    cur = postgresql.cursor()
    cur.execute("CREATE TABLE test (id serial PRIMARY KEY, num integer, data varchar);")
    postgresql.commit()
    cur.close()

And run tests:

pytest --postgresql-host=172.17.0.2 --postgresql-password=mysecretpassword

Using a common database initialisation between tests

If you've got several tests that require common initialisation, you need to define a load and pass it to your custom postgresql process fixture:

import pytest_postgresql.factories
def load_database(**kwargs):
    db_connection: connection = psycopg2.connect(**kwargs)
    with db_connection.cursor() as cur:
        cur.execute("CREATE TABLE stories (id serial PRIMARY KEY, name varchar);")
        cur.execute(
            "INSERT INTO stories (name) VALUES"
            "('Silmarillion'), ('Star Wars'), ('The Expanse'), ('Battlestar Galactica')"
        )
        db_connection.commit()

postgresql_proc = factories.postgresql_proc(
    load=[load_database],
)

postgresql = factories.postgresql(
    "postgresql_proc",
)

You can also define your own database name by passing same dbname value to both factories.

The way this will work is that the process fixture will populate template database, which in turn will be used automatically by client fixture to create a test database from scratch. Fast, clean and no dangling transactions, that could be accidentally rolled back.

Same approach will work with noproces fixture, while connecting to already running postgresql instance whether it'll be on a docker machine or running remotely or locally.

Comments
  • Breaks with pytest 7 due to private imports

    Breaks with pytest 7 due to private imports

    In https://github.com/pytest-dev/pytest/discussions/9415, we discovered that this plugin breaks with pytest 7.0.0rc1:

      File ".../pytest_postgresql/factories/process.py", line 27, in <module>
        from _pytest.tmpdir import TempdirFactory
    ImportError: cannot import name 'TempdirFactory' from '_pytest.tmpdir' (/usr/lib/python3.10/site-packages/_pytest/tmpdir.py)
    

    This is due to this class moving to a different place in pytest internally. Other places use similar private imports which still work, for now:

    tests/test_postgres_options_plugin.py
    3:from _pytest.pytester import Pytester
    
    src/pytest_postgresql/config.py
    1:from _pytest.fixtures import FixtureRequest
    
    src/pytest_postgresql/plugin.py
    22:from _pytest.config.argparsing import Parser
    
    tests/test_executor.py
    5:from _pytest.fixtures import FixtureRequest
    
    src/pytest_postgresql/factories/client.py
    22:from _pytest.fixtures import FixtureRequest
    
    src/pytest_postgresql/factories/noprocess.py
    23:from _pytest.fixtures import FixtureRequest
    
    src/pytest_postgresql/factories/process.py
    26:from _pytest.fixtures import FixtureRequest
    27:from _pytest.tmpdir import TempdirFactory
    

    With pytest 7.0.0, those types become publicly available, so it's recommended to import them from pytest directly instead, perhaps via a small compat layer which can be dropped once support for pytest<7 isn't relevant anymore.

    bug help wanted 
    opened by The-Compiler 13
  • Allow setting passwords

    Allow setting passwords

    Fixes #260.

    • Allow setting a password when using the janitor. (493cf29)

      I've made this a separate method as I think it's probably useful to a minority of users, and I don't want to break the existing interface for the constructor.

      It's tempting to use keyword args for the constructor, but that would also be a disruptive change.

    • Allow setting an optional password in the constructor. (5a3bde9)

      This avoids the need for an ugly setter just for this field.

    • Fold long line to fix lint. (722532e)

    • Allow passing a password in all of the places you can pass the other connection details. (8372fb013f8323aa30b72854d4edc42b7c53f987)

      initdb doesn't accept a password on the command line, so I'm using a temporary file that's deleted immediately after use.

    I've adjusted this to allow passing a password in the factories. Some of the tests won't run cleanly for me locally, so I'm having a little trouble adding more meaningful tests. Suggestions welcome.

    I believe initdb will accept a password while also using --auth=trust, but I don't have a good way to run that locally at present.

    opened by ashokdelphia 13
  • documention request: example for postgresql_nooproc usage

    documention request: example for postgresql_nooproc usage

    postgresql container spinned with docker-compose. Invoking query and asserting the result

    Didn't find a complete example/code snippet which does something similar. Would appreciate a code example.

    enhancement documentation 
    opened by lmilbaum 10
  • pytest-postgresql 2.0.0 broken on macOS (AttributeError: module 'select' has no attribute 'poll')

    pytest-postgresql 2.0.0 broken on macOS (AttributeError: module 'select' has no attribute 'poll')

    What action do you want to perform

    I have a minimal test file, test_postgres.py:

    def test_postgres(postgresql_proc):
        pass
    

    and I run pytest test_postgres.py on macOS 10.14.6.

    What are the results

    With pytest-postgresql I get the following error message.

    This is broken in pytest-postgresql 2.0.0. If I downgrade to pytest-postgresql <= 1.4.1 and mirakuru <= 1.1.0, it's not broken.

    (test) bash-3.2$ pytest test_postgres.py 
    Traceback (most recent call last):
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/bin/pytest", line 10, in <module>
        sys.exit(main())
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/site-packages/_pytest/config/__init__.py", line 58, in main
        config = _prepareconfig(args, plugins)
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/site-packages/_pytest/config/__init__.py", line 208, in _prepareconfig
        pluginmanager=pluginmanager, args=args
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/site-packages/pluggy/hooks.py", line 289, in __call__
        return self._hookexec(self, self.get_hookimpls(), kwargs)
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/site-packages/pluggy/manager.py", line 87, in _hookexec
        return self._inner_hookexec(hook, methods, kwargs)
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/site-packages/pluggy/manager.py", line 81, in <lambda>
        firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/site-packages/pluggy/callers.py", line 203, in _multicall
        gen.send(outcome)
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/site-packages/_pytest/helpconfig.py", line 89, in pytest_cmdline_parse
        config = outcome.get_result()
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
        raise ex[1].with_traceback(ex[2])
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
        res = hook_impl.function(*args)
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/site-packages/_pytest/config/__init__.py", line 716, in pytest_cmdline_parse
        self.parse(args)
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/site-packages/_pytest/config/__init__.py", line 924, in parse
        self._preparse(args, addopts=addopts)
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/site-packages/_pytest/config/__init__.py", line 870, in _preparse
        self.pluginmanager.load_setuptools_entrypoints("pytest11")
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/site-packages/pluggy/manager.py", line 292, in load_setuptools_entrypoints
        plugin = ep.load()
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/site-packages/importlib_metadata/__init__.py", line 90, in load
        module = import_module(match.group('module'))
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/importlib/__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
      File "<frozen importlib._bootstrap>", line 983, in _find_and_load
      File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/site-packages/_pytest/assertion/rewrite.py", line 140, in exec_module
        exec(co, module.__dict__)
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/site-packages/pytest_postgresql/plugin.py", line 21, in <module>
        from pytest_postgresql import factories
      File "<frozen importlib._bootstrap>", line 983, in _find_and_load
      File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/site-packages/_pytest/assertion/rewrite.py", line 140, in exec_module
        exec(co, module.__dict__)
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/site-packages/pytest_postgresql/factories.py", line 33, in <module>
        from pytest_postgresql.executor import PostgreSQLExecutor
      File "<frozen importlib._bootstrap>", line 983, in _find_and_load
      File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/site-packages/_pytest/assertion/rewrite.py", line 140, in exec_module
        exec(co, module.__dict__)
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/site-packages/pytest_postgresql/executor.py", line 28, in <module>
        from mirakuru import TCPExecutor
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/site-packages/mirakuru/__init__.py", line 24, in <module>
        from mirakuru.output import OutputExecutor
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/site-packages/mirakuru/output.py", line 30, in <module>
        class OutputExecutor(SimpleExecutor):
      File "/Users/lpsinger/.local/share/virtualenvs/test-6C_DLGjE/lib/python3.7/site-packages/mirakuru/output.py", line 107, in OutputExecutor
        def _wait_for_output(self, *polls: Tuple[select.poll, IO[Any]]) -> bool:
    AttributeError: module 'select' has no attribute 'poll'
    

    What are the expected results

    (test) bash-3.2$ pytest test_postgres.py 
    ============================= test session starts ==============================
    platform darwin -- Python 3.7.4, pytest-5.1.1, py-1.8.0, pluggy-0.12.0
    rootdir: /private/tmp/test
    plugins: postgresql-1.4.1
    collected 1 item                                                               
    
    test_postgres.py .                                                       [100%]
    
    ============================== 1 passed in 1.20s ===============================
    
    help wanted input needed 
    opened by lpsinger 10
  • Weird error at shutdown

    Weird error at shutdown

    I'm getting the following error at the end of pytest's output when a test fails. It doesn't prevent a successful pass when everything is OK, though.

    ********************************************************************************
    Exception while deleting Executor. 'It is strongly suggested that you use
    it as a context manager instead.
    ********************************************************************************
    Exception ignored in: <bound method SimpleExecutor.__del__ of <pytest_postgresql.executor.PostgreSQLExecutor: "/usr/bin/p..." 0x7fe758d124a8>>
    Traceback (most recent call last):
      File "/home/lahwaacz/Bbox/pg/python3/wiki-scripts/.tox/py36/lib/python3.6/site-packages/mirakuru/base.py", line 361, in __del__
      File "/home/lahwaacz/Bbox/pg/python3/wiki-scripts/.tox/py36/lib/python3.6/site-packages/mirakuru/base.py", line 314, in kill
      File "/home/lahwaacz/Bbox/pg/python3/wiki-scripts/.tox/py36/lib/python3.6/site-packages/mirakuru/base.py", line 227, in _kill_all_kids
      File "/home/lahwaacz/Bbox/pg/python3/wiki-scripts/.tox/py36/lib/python3.6/site-packages/mirakuru/base_env.py", line 52, in processes_with_env_psutil
      File "/home/lahwaacz/Bbox/pg/python3/wiki-scripts/.tox/py36/lib/python3.6/site-packages/psutil/__init__.py", line 1426, in process_iter
      File "/home/lahwaacz/Bbox/pg/python3/wiki-scripts/.tox/py36/lib/python3.6/site-packages/psutil/__init__.py", line 1371, in pids
      File "/home/lahwaacz/Bbox/pg/python3/wiki-scripts/.tox/py36/lib/python3.6/site-packages/psutil/_pslinux.py", line 1324, in pids
      File "/home/lahwaacz/Bbox/pg/python3/wiki-scripts/.tox/py36/lib/python3.6/site-packages/psutil/_pslinux.py", line 214, in get_procfs_path
    KeyError: 'psutil'
    
    bug help wanted 
    opened by lahwaacz 9
  • Can't connect / timeout (Postgresql in docker container)?

    Can't connect / timeout (Postgresql in docker container)?

    Python 3.5.2 Postgresql 9.6.2 running inside docker container with exposed ports (so I can run psql locally) Port: 5432

    tests are blocked

    (storm) ➜  src git:(develop) ✗ pytest -v 
    ============================================================================================================= test session starts =============================================================================================================
    platform linux -- Python 3.5.2, pytest-3.0.7, py-1.4.33, pluggy-0.4.0 -- /home/dmitry/.pyenv/versions/3.5.2/envs/storm/bin/python
    cachedir: .cache
    rootdir: /home/dmitry/Projects/trivver/storm/src, inifile:
    plugins: xdist-1.16.0, postgresql-1.2.0, cov-2.4.0
    collected 5 items 
    
    cache/tests/lru_test.py::TestCacheLRU::test_get_session_user  ^C
    

    So my execution stuck inside test_get_session_user()

    code:

    postgresql_proc = factories.postgresql_proc(user='postgres')
    postgresql = factories.postgresql('postgresql_proc')
    
    
    class TestCacheLRU(object):
        def test_get_session_user(self, postgresql):
    
            cur = postgresql.cursor()
            cur.execute(
                'CREATE TABLE test (id serial PRIMARY KEY, num integer, data varchar);')
            postgresql.commit()
            cur.close()
    
            assert lru.get_session_user(None) is None
    
    question 
    opened by dmitry-saritasa 9
  • need help to understand documentation

    need help to understand documentation

    hi all,

    Can any one explain me what are these tests files in tests dir of the source code ? test_executor.py, test_janitor.py, test_noopexecutor.py

    what is executor, janitor and noopexecutor? how can some one use these features in his testing?

    I have used factories.postgresql_proc() and factories.postgresql() in my trial project and it is working fine. But not sure about others. I find little difficult to understand the documentation as a pytest newbie.

    -Thanks

    question 
    opened by ravi2k16 8
  • Does not work in some earlier versions of python 3.5

    Does not work in some earlier versions of python 3.5

    What action do you want to perform

    I want to use the postgresql fixture in a test. I have python 3.5.2 and pytest-postgresql 2.1.0.

    What are the results

      File "/opt/venvs/test/bin/pytest", line 10, in <module>
        sys.exit(main())
      File "/opt/venvs/test/lib/python3.5/site-packages/_pytest/config/__init__.py", line 58, in main
        config = _prepareconfig(args, plugins)
      File "/opt/venvs/test/lib/python3.5/site-packages/_pytest/config/__init__.py", line 208, in _prepareconfig
        pluginmanager=pluginmanager, args=args
      File "/opt/venvs/test/lib/python3.5/site-packages/pluggy/hooks.py", line 286, in __call__
        return self._hookexec(self, self.get_hookimpls(), kwargs)
      File "/opt/venvs/test/lib/python3.5/site-packages/pluggy/manager.py", line 92, in _hookexec
        return self._inner_hookexec(hook, methods, kwargs)
      File "/opt/venvs/test/lib/python3.5/site-packages/pluggy/manager.py", line 86, in <lambda>
        firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
      File "/opt/venvs/test/lib/python3.5/site-packages/pluggy/callers.py", line 203, in _multicall
        gen.send(outcome)
      File "/opt/venvs/test/lib/python3.5/site-packages/_pytest/helpconfig.py", line 89, in pytest_cmdline_parse
        config = outcome.get_result()
      File "/opt/venvs/test/lib/python3.5/site-packages/pluggy/callers.py", line 80, in get_result
        raise ex[1].with_traceback(ex[2])
      File "/opt/venvs/test/lib/python3.5/site-packages/pluggy/callers.py", line 187, in _multicall
        res = hook_impl.function(*args)
      File "/opt/venvs/test/lib/python3.5/site-packages/_pytest/config/__init__.py", line 719, in pytest_cmdline_parse
        self.parse(args)
      File "/opt/venvs/test/lib/python3.5/site-packages/_pytest/config/__init__.py", line 927, in parse
        self._preparse(args, addopts=addopts)
      File "/opt/venvs/test/lib/python3.5/site-packages/_pytest/config/__init__.py", line 873, in _preparse
        self.pluginmanager.load_setuptools_entrypoints("pytest11")
      File "/opt/venvs/test/lib/python3.5/site-packages/pluggy/manager.py", line 297, in load_setuptools_entrypoints
        plugin = ep.load()
      File "/opt/venvs/test/lib/python3.5/site-packages/importlib_metadata/__init__.py", line 92, in load
        module = import_module(match.group('module'))
      File "/opt/venvs/test/lib/python3.5/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 986, in _gcd_import
      File "<frozen importlib._bootstrap>", line 969, in _find_and_load
      File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
      File "/opt/venvs/test/lib/python3.5/site-packages/_pytest/assertion/rewrite.py", line 140, in exec_module
        exec(co, module.__dict__)
      File "/opt/venvs/test/lib/python3.5/site-packages/pytest_postgresql/plugin.py", line 21, in <module>
        from pytest_postgresql import factories
      File "<frozen importlib._bootstrap>", line 969, in _find_and_load
      File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
      File "/opt/venvs/test/lib/python3.5/site-packages/_pytest/assertion/rewrite.py", line 140, in exec_module
        exec(co, module.__dict__)
      File "/opt/venvs/test/lib/python3.5/site-packages/pytest_postgresql/factories.py", line 28, in <module>
        from pytest_postgresql.janitor import DatabaseJanitor, psycopg2
      File "<frozen importlib._bootstrap>", line 969, in _find_and_load
      File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
      File "/opt/venvs/test/lib/python3.5/site-packages/_pytest/assertion/rewrite.py", line 140, in exec_module
        exec(co, module.__dict__)
      File "/opt/venvs/test/lib/python3.5/site-packages/pytest_postgresql/janitor.py", line 23, in <module>
        class DatabaseJanitor:
      File "/opt/venvs/test/lib/python3.5/site-packages/pytest_postgresql/janitor.py", line 94, in DatabaseJanitor
        exc_type: Optional[Type[BaseException]],
      File "/usr/lib/python3.5/typing.py", line 649, in __getitem__
        return Union[arg, type(None)]
      File "/usr/lib/python3.5/typing.py", line 552, in __getitem__
        dict(self.__dict__), parameters, _root=True)
      File "/usr/lib/python3.5/typing.py", line 512, in __new__
        for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
      File "/usr/lib/python3.5/typing.py", line 512, in <genexpr>
        for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
      File "/usr/lib/python3.5/typing.py", line 1077, in __subclasscheck__
        if super().__subclasscheck__(cls):
      File "/opt/venvs/test/lib/python3.5/abc.py", line 225, in __subclasscheck__
        for scls in cls.__subclasses__():
    TypeError: descriptor '__subclasses__' of 'type' object needs an argument
    

    What are the expected results

    Including postgresql fixture should not cause this exception(?)

    Upon a little further digging, I found that the version of mirakuru installed requires python 3.6 or later. Downgrading mirikuru to 1.1.0 and pytest-postgresql to 1.4.1 got things to work, but at the cost of installing a version of mirakuru that is incompatible according to the specifications.

    In this commit: https://github.com/ClearcodeHQ/pytest-postgresql/commit/76e6605e19450fe37faabf8679332d66a597529b I see someone pinning to <2.1.0 for python3.5, possibly to fix this. However, 2.0.1 appears to be the only version that suits the hard-coded requirements, but it doesn't fix the problem. Downgrading mirakuru to 1.1.0 eliminated the traceback I reported above, but still threw the same exception at a different point in code.

    opened by rschwiebert 7
  • Unable to set database password

    Unable to set database password

    Hi Thanks for the great library. I found the issue while trying to set the password in the fixture. I tried to set the password by 2 ways, the first is by the factory object and the second by pytest.ini and in both cases the error was the same:

    TypeError: can only concatenate tuple (not "str") to tuple
    

    It seems like the flaw is located in pytest_postgresql/executor.py file in these lines:

            if self.password:
                with tempfile.NamedTemporaryFile() as password_file:
                    init_directory += (
                        '--pwfile "%s"' % password_file.name
                    )
    

    Here you are trying to concatenate string to init_directory variable which as we can see here:

            init_directory = (
                self.executable, 'initdb',
                '-o "--auth=trust --username=%s"' % self.user,
                '-D %s' % self.datadir,
            )
    

    ...is a tuple. So the problem is simply lack of the comma. I can fix this on today's evening (Polish time) if you don't mind it. I really need that to be fixed quickly.

    bug 
    opened by wolkiewiczk 6
  • Fix docs lint warning

    Fix docs lint warning

    Fix pyroma lint warning.

    It's complaining about the underline being shorter than the heading:

    Before:

    $ pyroma .
    ------------------------------
    Checking .
    Found pytest-postgresql
    ------------------------------
    Your long_description is not valid ReST: 
    <string>:239: (WARNING/2) Title underline too short.
    
    unreleased
    -------
    ------------------------------
    Final rating: 9/10
    Cottage Cheese
    ------------------------------
    

    After:

    $ pyroma .
    ------------------------------
    Checking .
    Found pytest-postgresql
    ------------------------------
    Final rating: 10/10
    Your cheese is so fresh most people think it's a cream: Mascarpone
    ------------------------------
    

    (This seemed too trivial to warrant an issue; please advise if you would like one for completeness.)

    opened by ashokdelphia 6
  • TypeError: '>=' not supported between instances of 'float' and 'Version'

    TypeError: '>=' not supported between instances of 'float' and 'Version'

    Tried upgrading to 2.0.0 and same problem

        @request.addfinalizer
        def drop_database():
    >       drop_postgresql_database(pg_user, pg_host, pg_port, pg_db, 11.2)
    
    qc/test/conftest.py:46: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    
    user = None, host = None, port = None, db_name = 'qc_test', version = 11.2
    
        def drop_postgresql_database(user, host, port, db_name, version):
            """
            Drop databse in postgresql.
        
            :param str user: postgresql username
            :param str host: postgresql host
            :param str port: postgresql port
            :param str db_name: database name
            :param packaging.version.Version version: postgresql version number
            """
            conn = psycopg2.connect(user=user, host=host, port=port)
            conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
            cur = conn.cursor()
            # We cannot drop the database while there are connections to it, so we
            # terminate all connections first while not allowing new connections.
    >       if version >= parse_version('9.2'):
    E       TypeError: '>=' not supported between instances of 'float' and 'Version'
    
    ../../../../.virtualenvs/qc-backend-qjdNaO4n/lib/python3.7/site-packages/pytest_postgresql/factories.p:
    84: TypeError                                                                                         
    
    question 
    opened by revmischa 6
  • Bump ridedott/merge-me-action from 2.10.31 to 2.10.42

    Bump ridedott/merge-me-action from 2.10.31 to 2.10.42

    Bumps ridedott/merge-me-action from 2.10.31 to 2.10.42.

    Release notes

    Sourced from ridedott/merge-me-action's releases.

    v2.10.42

    2.10.42 (2023-01-06)

    Chores

    • deps-dev: bump @​ridedott/eslint-config from 2.22.15 to 2.22.17 (da4ce3a)
    • deps-dev: bump @​ridedott/eslint-config from 2.22.17 to 2.22.18 (aae7670)
    • deps: bump actions/setup-node from 3.5.1 to 3.6.0 (8547c88)

    v2.10.41

    2.10.41 (2023-01-04)

    Chores

    • deps-dev: bump @​commitlint/cli from 17.3.0 to 17.4.0 (8cdc271)
    • deps-dev: bump @​commitlint/config-conventional (fc1cb49)
    • deps-dev: bump @​ridedott/eslint-config from 2.22.13 to 2.22.14 (d8ee7d6)
    • deps-dev: bump @​ridedott/eslint-config from 2.22.14 to 2.22.15 (269c1f8)
    • deps-dev: bump eslint from 8.30.0 to 8.31.0 (f555381)
    • deps-dev: bump husky from 8.0.2 to 8.0.3 (a31b5cb)
    • deps: bump json5 from 1.0.1 to 1.0.2 (f4ccc7a)

    v2.10.40

    2.10.40 (2022-12-30)

    Chores

    • deps-dev: bump @​ridedott/eslint-config from 2.21.0 to 2.21.1 (42e3ee4)
    • deps-dev: bump @​ridedott/eslint-config from 2.22.11 to 2.22.13 (ce2a056)
    • deps-dev: bump @​ridedott/eslint-config from 2.22.5 to 2.22.6 (8de39f2)
    • deps-dev: bump @​ridedott/eslint-config from 2.22.6 to 2.22.8 (9f07e77)
    • deps-dev: bump @​ridedott/eslint-config from 2.22.8 to 2.22.9 (7e80e97)
    • deps-dev: bump @​ridedott/eslint-config from 2.22.9 to 2.22.11 (1b58c5f)
    • deps-dev: bump cspell from 6.17.0 to 6.18.0 (5373b36)
    • deps-dev: bump cspell from 6.18.0 to 6.18.1 (4b1c974)
    • deps-dev: bump eslint and @​ridedott/eslint-config (08545ea)
    • deps-dev: bump eslint from 8.29.0 to 8.30.0 (6491b08)
    • deps: bump ridedott/release-me-action from 3.7.1 to 3.7.2 (d2067ee)

    v2.10.39

    2.10.39 (2022-12-08)

    Chores

    • deps-dev: bump @​ridedott/eslint-config from 2.20.66 to 2.21.0 (ce0c7ba)
    • deps-dev: bump prettier from 2.8.0 to 2.8.1 (40c4a1a)

    ... (truncated)

    Changelog

    Sourced from ridedott/merge-me-action's changelog.

    2.10.42 (2023-01-06)

    Chores

    • deps-dev: bump @​ridedott/eslint-config from 2.22.15 to 2.22.17 (da4ce3a)
    • deps-dev: bump @​ridedott/eslint-config from 2.22.17 to 2.22.18 (aae7670)
    • deps: bump actions/setup-node from 3.5.1 to 3.6.0 (8547c88)

    2.10.41 (2023-01-04)

    Chores

    • deps-dev: bump @​commitlint/cli from 17.3.0 to 17.4.0 (8cdc271)
    • deps-dev: bump @​commitlint/config-conventional (fc1cb49)
    • deps-dev: bump @​ridedott/eslint-config from 2.22.13 to 2.22.14 (d8ee7d6)
    • deps-dev: bump @​ridedott/eslint-config from 2.22.14 to 2.22.15 (269c1f8)
    • deps-dev: bump eslint from 8.30.0 to 8.31.0 (f555381)
    • deps-dev: bump husky from 8.0.2 to 8.0.3 (a31b5cb)
    • deps: bump json5 from 1.0.1 to 1.0.2 (f4ccc7a)

    2.10.40 (2022-12-30)

    Chores

    • deps-dev: bump @​ridedott/eslint-config from 2.21.0 to 2.21.1 (42e3ee4)
    • deps-dev: bump @​ridedott/eslint-config from 2.22.11 to 2.22.13 (ce2a056)
    • deps-dev: bump @​ridedott/eslint-config from 2.22.5 to 2.22.6 (8de39f2)
    • deps-dev: bump @​ridedott/eslint-config from 2.22.6 to 2.22.8 (9f07e77)
    • deps-dev: bump @​ridedott/eslint-config from 2.22.8 to 2.22.9 (7e80e97)
    • deps-dev: bump @​ridedott/eslint-config from 2.22.9 to 2.22.11 (1b58c5f)
    • deps-dev: bump cspell from 6.17.0 to 6.18.0 (5373b36)
    • deps-dev: bump cspell from 6.18.0 to 6.18.1 (4b1c974)

    ... (truncated)

    Commits
    • cf08b62 chore(release): v2.10.42
    • aae7670 chore(deps-dev): bump @​ridedott/eslint-config from 2.22.17 to 2.22.18
    • 8547c88 chore(deps): bump actions/setup-node from 3.5.1 to 3.6.0
    • da4ce3a chore(deps-dev): bump @​ridedott/eslint-config from 2.22.15 to 2.22.17
    • 158dbe6 chore(release): v2.10.41
    • 8cdc271 chore(deps-dev): bump @​commitlint/cli from 17.3.0 to 17.4.0
    • f4ccc7a chore(deps): bump json5 from 1.0.1 to 1.0.2
    • fc1cb49 chore(deps-dev): bump @​commitlint/config-conventional
    • a31b5cb chore(deps-dev): bump husky from 8.0.2 to 8.0.3
    • 269c1f8 chore(deps-dev): bump @​ridedott/eslint-config from 2.22.14 to 2.22.15
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies github_actions 
    opened by dependabot[bot] 1
  • Clarification of text in README.md

    Clarification of text in README.md

    What action do you want to perform

    I'm struggling to understand the following excerpt from the README.md. I have postgresql running in a docker container with an existing database ('foo', for example) pre-populated with tables and data. I read the following excerpt and thought that if I specify my database 'foo' for both factory calls, it would copy the contents of 'foo' to the 'test' database. That doesn't appear to be the case. I might be misunderstanding the terms used in this text.

    You can also define your own database name by passing same dbname value to both factories.

    The way this will work is that the process fixture will populate template database, which in turn will be used automatically by client fixture to create a test database from scratch. Fast, clean and no dangling transactions, that could be accidentally rolled back.

    Same approach will work with noproces fixture, while connecting to already running postgresql instance whether it'll be on a docker machine or running remotely or locally.

    It appears I could write a function to copy the 'foo' database to the 'test' database and provide that function name in the "load" argument to the factory to achieve the desired results. But I wanted to verify there wasn't an easier way per the text above.

    enhancement 
    opened by kbalk-maxar 1
  • Bump pyflakes from 2.5.0 to 3.0.1

    Bump pyflakes from 2.5.0 to 3.0.1

    Bumps pyflakes from 2.5.0 to 3.0.1.

    Changelog

    Sourced from pyflakes's changelog.

    3.0.1 (2022-11-24)

    • Fix crash on augmented assign to print builtin

    3.0.0 (2022-11-23)

    • Detect undefined name in variable defined by an annotated assignment
    • Add a new error for names which are annotated but unused
    • Remove handling of python 2.x # type: comments. Use annotations instead
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies python 
    opened by dependabot[bot] 1
  • Using postgresql_noproc in a different files

    Using postgresql_noproc in a different files

    What action do you want to perform

    define this fixture in two separate files containing one test each using it postgresql_noproc = factories.postgresql_noproc( load=["whatever.sql"], dbname="tests" )

    postgresql = factories.postgresql( "postgresql_noproc", dbname="tests" )

    run a common postgres in a docker container;

    What are the results

    self = <psycopg.Cursor [closed] [BAD] at 0x7fe15841df40>, query = 'CREATE DATABASE "tests_tmpl";', params = None

    def execute(
        self: _Self,
        query: Query,
        params: Optional[Params] = None,
        *,
        prepare: Optional[bool] = None,
        binary: Optional[bool] = None,
    ) -> _Self:
        """
        Execute a query or command to the database.
        """
        try:
            with self._conn.lock:
                self._conn.wait(
                    self._execute_gen(query, params, prepare=prepare, binary=binary)
                )
        except e.Error as ex:
    
          raise ex.with_traceback(None)
    

    E psycopg.errors.DuplicateDatabase: database "tests_tmpl" already exists

    /usr/local/lib/python3.9/dist-packages/psycopg/cursor.py:725: DuplicateDatabase

    What are the expected results

    That test doesn't fails; it's limiting to define all the tests in a single file

    question 
    opened by tassadar81 3
  • Bump mypy from 0.982 to 0.991

    Bump mypy from 0.982 to 0.991

    Bumps mypy from 0.982 to 0.991.

    Commits
    • b7788fc Update version to remove "+dev" for releasing 0.991
    • 6077d19 manually CP typeshed #9130
    • ab0ea1e Fix crash with function redefinition (#14064)
    • 592a9ce Fix another crash with report generation on namespace packages (#14063)
    • 1650ae0 Update --no-warn-no-return docs for empty body changes (#14065)
    • b9daa31 Don't ignore errors in files passed on the command line (#14060)
    • 02fd8a5 Filter out wasm32 wheel in upload-pypi.py (#14035)
    • 131c8d7 Fix crash on inference with recursive alias to recursive instance (#14038)
    • 1368338 Change version to 0.991+dev in preparation for the point release
    • b71dc3d Remove +dev from version
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies python 
    opened by dependabot[bot] 1
Owner
Clearcode
Software house with a passion for technology. We specialize in building enterprise-grade adtech, martech and analytics platforms.
Clearcode
A pytest plugin that enables you to test your code that relies on a running Elasticsearch search engine

pytest-elasticsearch What is this? This is a pytest plugin that enables you to test your code that relies on a running Elasticsearch search engine. It

Clearcode 65 Nov 10, 2022
pytest plugin providing a function to check if pytest is running.

pytest-is-running pytest plugin providing a function to check if pytest is running. Installation Install with: python -m pip install pytest-is-running

Adam Johnson 21 Nov 1, 2022
Pytest-typechecker - Pytest plugin to test how type checkers respond to code

pytest-typechecker this is a plugin for pytest that allows you to create tests t

vivax 2 Aug 20, 2022
A pytest plugin to run an ansible collection's unit tests with pytest.

pytest-ansible-units An experimental pytest plugin to run an ansible collection's unit tests with pytest. Description pytest-ansible-units is a pytest

Community managed Ansible repositories 9 Dec 9, 2022
pytest plugin that let you automate actions and assertions with test metrics reporting executing plain YAML files

pytest-play pytest-play is a codeless, generic, pluggable and extensible automation tool, not necessarily test automation only, based on the fantastic

pytest-dev 67 Dec 1, 2022
pytest plugin for manipulating test data directories and files

pytest-datadir pytest plugin for manipulating test data directories and files. Usage pytest-datadir will look up for a directory with the name of your

Gabriel Reis 191 Dec 21, 2022
pytest plugin for a better developer experience when working with the PyTorch test suite

pytest-pytorch What is it? pytest-pytorch is a lightweight pytest-plugin that enhances the developer experience when working with the PyTorch test sui

Quansight 39 Nov 18, 2022
ApiPy was created for api testing with Python pytest framework which has also requests, assertpy and pytest-html-reporter libraries.

ApiPy was created for api testing with Python pytest framework which has also requests, assertpy and pytest-html-reporter libraries. With this f

Mustafa 1 Jul 11, 2022
Playwright Python tool practice pytest pytest-bdd screen-play page-object allure cucumber-report

pytest-ui-automatic Playwright Python tool practice pytest pytest-bdd screen-play page-object allure cucumber-report How to run Run tests execute_test

moyu6027 11 Nov 8, 2022
Pytest-rich - Pytest + rich integration (proof of concept)

pytest-rich Leverage rich for richer test session output. This plugin is not pub

Bruno Oliveira 170 Dec 2, 2022
Set your Dynaconf environment to testing when running pytest

pytest-dynaconf Set your Dynaconf environment to testing when running pytest. Installation You can install "pytest-dynaconf" via pip from PyPI: $ pip

David Baumgold 3 Mar 11, 2022
a plugin for py.test that changes the default look and feel of py.test (e.g. progressbar, show tests that fail instantly)

pytest-sugar pytest-sugar is a plugin for pytest that shows failures and errors instantly and shows a progress bar. Requirements You will need the fol

Teemu 963 Dec 28, 2022
A set of pytest fixtures to test Flask applications

pytest-flask An extension of pytest test runner which provides a set of useful tools to simplify testing and development of the Flask extensions and a

pytest-dev 433 Dec 23, 2022
Selects tests affected by changed files. Continous test runner when used with pytest-watch.

This is a pytest plug-in which automatically selects and re-executes only tests affected by recent changes. How is this possible in dynamic language l

Tibor Arpas 614 Dec 30, 2022
Local continuous test runner with pytest and watchdog.

pytest-watch -- Continuous pytest runner pytest-watch a zero-config CLI tool that runs pytest, and re-runs it when a file in your project changes. It

Joe Esposito 675 Dec 23, 2022
A set of pytest fixtures to test Flask applications

pytest-flask An extension of pytest test runner which provides a set of useful tools to simplify testing and development of the Flask extensions and a

pytest-dev 354 Feb 17, 2021
API Test Automation with Requests and Pytest

api-testing-requests-pytest Install Make sure you have Python 3 installed on your machine. Then: 1.Install pipenv sudo apt-get install pipenv 2.Go to

Sulaiman Haque 2 Nov 21, 2021
a wrapper around pytest for executing tests to look for test flakiness and runtime regression

bubblewrap a wrapper around pytest for assessing flakiness and runtime regressions a cs implementations practice project How to Run: First, install de

Anna Nagy 1 Aug 5, 2021
Front End Test Automation with Pytest Framework

Front End Test Automation Framework with Pytest Installation and running instructions: 1. To install the framework on your local machine: clone the re

Sergey Kolokolov 2 Jun 17, 2022