{"id":15654922,"url":"https://github.com/idlesign/pytest-datafixtures","last_synced_at":"2025-05-04T07:41:17.447Z","repository":{"id":57456499,"uuid":"262920006","full_name":"idlesign/pytest-datafixtures","owner":"idlesign","description":"Data fixtures for pytest made simple","archived":false,"fork":false,"pushed_at":"2022-02-04T13:01:58.000Z","size":13,"stargazers_count":25,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-13T08:06:15.154Z","etag":null,"topics":["datafixture","fixtures","pytest","pytest-plugin","python","python3"],"latest_commit_sha":null,"homepage":"https://github.com/idlesign/pytest-datafixtures","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/idlesign.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG","contributing":"CONTRIBUTING","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-11T02:32:27.000Z","updated_at":"2023-09-08T18:07:17.000Z","dependencies_parsed_at":"2022-09-14T05:20:54.378Z","dependency_job_id":null,"html_url":"https://github.com/idlesign/pytest-datafixtures","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idlesign%2Fpytest-datafixtures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idlesign%2Fpytest-datafixtures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idlesign%2Fpytest-datafixtures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idlesign%2Fpytest-datafixtures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/idlesign","download_url":"https://codeload.github.com/idlesign/pytest-datafixtures/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252135358,"owners_count":21699887,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["datafixture","fixtures","pytest","pytest-plugin","python","python3"],"created_at":"2024-10-03T12:54:52.712Z","updated_at":"2025-05-03T02:52:34.247Z","avatar_url":"https://github.com/idlesign.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"pytest-datafixtures\n===================\nhttps://github.com/idlesign/pytest-datafixtures\n\n|release| |lic| |ci| |coverage|\n\n.. |release| image:: https://img.shields.io/pypi/v/pytest-datafixtures.svg\n    :target: https://pypi.python.org/pypi/pytest-datafixtures\n\n.. |lic| image:: https://img.shields.io/pypi/l/pytest-datafixtures.svg\n    :target: https://pypi.python.org/pypi/pytest-datafixtures\n\n.. |ci| image:: https://img.shields.io/travis/idlesign/pytest-datafixtures/master.svg\n    :target: https://travis-ci.org/idlesign/pytest-datafixtures\n\n.. |coverage| image:: https://img.shields.io/coveralls/idlesign/pytest-datafixtures/master.svg\n    :target: https://coveralls.io/r/idlesign/pytest-datafixtures\n\n\nDescription\n-----------\n\n*Data fixtures for pytest made simple*\n\nOffers fixtures for your tests to simplify data fixtures access.\nMakes use of Python's native ``Path`` objects.\n\nData fixtures (files) expected to be stored in ``datafixtures`` directory next to your test modules::\n\n    tests\n    |-- datafixtures\n    |-- test_basic.py\n    |\n    |-- subdirectory\n    |---- datafixtures\n    |---- test_other.py\n\n\n\n**Fixtures**\n\n* ``datafix_dir`` - Path object for data fixtures directory from the current test module's directory.\n* ``datafix`` - Path object for a file in data fixtures directory with the same name as the current test function.\n* ``datafix_read`` - Returns text contents of a data fixture by name.\n* ``datafix_readbin`` - Returns binary contents of a data fixture by name.\n\n\ndatafix_dir\n~~~~~~~~~~~~~~~\n\nAccess data fixtures directory:\n\n.. code-block:: python\n\n    def test_me(datafix_dir):\n\n        # datafix_dir returns a Path object.\n        assert datafix_dir.exists()\n\n        # Gather data fixtures filenames.\n        files = list(f'{file.name}' for file in datafix_dir.iterdir())\n\n        # Read some fixture as text.\n        # The same as using `datafix_read` fixture (see below).\n        filecontent = (datafix_dir / 'expected.html').read_text()\n\n        # Or read binary.\n        filecontent = (datafix_dir / 'dumped.bin').read_bytes()\n\n\ndatafix\n~~~~~~~\n\nAccess a data fixture with test name:\n\n.. code-block:: python\n\n    def test_me(datafix):\n        # Read datafixtures/test_me.txt file\n        filecontents = datafix.with_suffix('.txt').read_text()\n\n\ndatafix_read\n~~~~~~~~~~~~\n\nAccess text contents of a data fixture by name:\n\n.. code-block:: python\n\n    def test_datafix_read(datafix_read):\n        # Read datafixtures/expected.html file\n        filecontents = datafix_read('expected.html')\n\n        # Read encoded and represent as an StringIO object.\n        encoded_io = datafix_read('test_datafix.txt', encoding='cp1251', io=True)\n\n\ndatafix_readbin\n~~~~~~~~~~~~~~~\n\nAccess binary contents of a data fixture by name:\n\n.. code-block:: python\n\n    def test_datafix_read(datafix_readbin):\n        # Read datafixtures/dumped.bin file\n        binary = datafix_readbin('dumped.bin')\n\n        # Read binary and represent as an BytesIO object.\n        bin_io = datafix_readbin('dumped.bin', io=True)\n\n\n\nRequirements\n------------\n* Python 3.6+\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidlesign%2Fpytest-datafixtures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidlesign%2Fpytest-datafixtures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidlesign%2Fpytest-datafixtures/lists"}