All Projects → idlesign → pytest-datafixtures

idlesign / pytest-datafixtures

Licence: BSD-3-Clause license
Data fixtures for pytest made simple

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to pytest-datafixtures

pytest-dependency
Manage dependencies of tests
Stars: ✭ 113 (+370.83%)
Mutual labels:  pytest, pytest-plugin
pytest-subprocess
Pytest plugin to fake subprocess.
Stars: ✭ 83 (+245.83%)
Mutual labels:  pytest, pytest-plugin
Seleniumbase
A Python framework that inspires developers to become better test automation engineers. 🧠💡
Stars: ✭ 2,520 (+10400%)
Mutual labels:  pytest, pytest-plugin
pytest-djangoapp
Nice pytest plugin to help you with Django pluggable application testing.
Stars: ✭ 35 (+45.83%)
Mutual labels:  pytest, pytest-plugin
overhave
Web-framework for BDD: scalable, configurable, easy to use, based on Flask Admin and Pydantic.
Stars: ✭ 61 (+154.17%)
Mutual labels:  pytest, pytest-plugin
pytest-reportlog
Replacement for the --resultlog option, focused in simplicity and extensibility
Stars: ✭ 36 (+50%)
Mutual labels:  pytest, pytest-plugin
pytest-involve
A pytest plugin to run tests pertaining to a specific file or changeset
Stars: ✭ 28 (+16.67%)
Mutual labels:  pytest, pytest-plugin
pytest-localstack
Pytest plugin for local AWS integration tests
Stars: ✭ 66 (+175%)
Mutual labels:  pytest, pytest-plugin
pytest-neo
Matrix has you...
Stars: ✭ 44 (+83.33%)
Mutual labels:  pytest, pytest-plugin
Pytest Deadfixtures
Plugin to list unused fixtures in your tests
Stars: ✭ 89 (+270.83%)
Mutual labels:  fixtures, pytest
pytest-pycodestyle
pytest plugin to run pycodestyle
Stars: ✭ 15 (-37.5%)
Mutual labels:  pytest, pytest-plugin
pytest-docker-tools
Opionated helpers for creating py.test fixtures for Docker integration and smoke testing environments
Stars: ✭ 61 (+154.17%)
Mutual labels:  pytest, pytest-plugin
pytest-arraydiff
pytest plugin to facilitate comparison of results to a pre-defined reference
Stars: ✭ 12 (-50%)
Mutual labels:  pytest, pytest-plugin
Pudb
Full-screen console debugger for Python
Stars: ✭ 2,267 (+9345.83%)
Mutual labels:  pytest, pytest-plugin
pytest-snapshot
A plugin for snapshot testing with pytest.
Stars: ✭ 68 (+183.33%)
Mutual labels:  pytest, pytest-plugin
lovely-pytest-docker
Pytest plugin providing the ability to use docker-compose services as fixtures.
Stars: ✭ 73 (+204.17%)
Mutual labels:  fixtures, pytest
pytest-eth
PyTest plugin for testing smart contracts for Ethereum blockchain.
Stars: ✭ 23 (-4.17%)
Mutual labels:  pytest, pytest-plugin
pytest-notebook
A pytest plugin for regression testing and regenerating Jupyter Notebooks
Stars: ✭ 35 (+45.83%)
Mutual labels:  pytest, pytest-plugin
Pytest Mimesis
Mimesis integration with the pytest test runner. This plugin provider useful fixtures based on providers from Mimesis.
Stars: ✭ 46 (+91.67%)
Mutual labels:  fixtures, pytest
pytest-datafiles
pytest plugin to create a tmpdir containing a preconfigured set of files and/or directories.
Stars: ✭ 75 (+212.5%)
Mutual labels:  pytest, pytest-plugin

pytest-datafixtures

https://github.com/idlesign/pytest-datafixtures

release lic ci coverage

Description

Data fixtures for pytest made simple

Offers fixtures for your tests to simplify data fixtures access. Makes use of Python's native Path objects.

Data fixtures (files) expected to be stored in datafixtures directory next to your test modules:

tests
|-- datafixtures
|-- test_basic.py
|
|-- subdirectory
|---- datafixtures
|---- test_other.py

Fixtures

  • datafix_dir - Path object for data fixtures directory from the current test module's directory.
  • datafix - Path object for a file in data fixtures directory with the same name as the current test function.
  • datafix_read - Returns text contents of a data fixture by name.
  • datafix_readbin - Returns binary contents of a data fixture by name.

datafix_dir

Access data fixtures directory:

def test_me(datafix_dir):

    # datafix_dir returns a Path object.
    assert datafix_dir.exists()

    # Gather data fixtures filenames.
    files = list(f'{file.name}' for file in datafix_dir.iterdir())

    # Read some fixture as text.
    # The same as using `datafix_read` fixture (see below).
    filecontent = (datafix_dir / 'expected.html').read_text()

    # Or read binary.
    filecontent = (datafix_dir / 'dumped.bin').read_bytes()

datafix

Access a data fixture with test name:

def test_me(datafix):
    # Read datafixtures/test_me.txt file
    filecontents = datafix.with_suffix('.txt').read_text()

datafix_read

Access text contents of a data fixture by name:

def test_datafix_read(datafix_read):
    # Read datafixtures/expected.html file
    filecontents = datafix_read('expected.html')

    # Read encoded and represent as an StringIO object.
    encoded_io = datafix_read('test_datafix.txt', encoding='cp1251', io=True)

datafix_readbin

Access binary contents of a data fixture by name:

def test_datafix_read(datafix_readbin):
    # Read datafixtures/dumped.bin file
    binary = datafix_readbin('dumped.bin')

    # Read binary and represent as an BytesIO object.
    bin_io = datafix_readbin('dumped.bin', io=True)

Requirements

  • Python 3.6+
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].