{"id":28110,"library":"pytest-xfiles","title":"pytest-xfiles","description":"pytest-xfiles provides fixtures that read test data from files named after the test function, module, or package (xfiles). Current version 0.2.0, with no recent updates; likely in maintenance mode.","status":"active","version":"0.2.0","language":"python","source_language":"en","source_url":"https://github.com/vlcinsky/pytest_xfiles","tags":["pytest","fixtures","test-data","xfiles","testing"],"install":[{"cmd":"pip install pytest-xfiles","lang":"bash","label":"Stable install"}],"dependencies":[],"imports":[{"note":"Avoid importing from 'pytest_xfiles.plugin' directly.","symbol":"xfiles","correct":"from pytest_xfiles import xfiles"}],"quickstart":{"code":"import pytest\n\ndef test_read_func_xfile(xfiles):\n    \"\"\"Test function-level xfile.\"\"\"\n    # The fixture returns a reader function\n    data = xfiles()\n    assert data is not None\n","lang":"python","description":"Basic usage: declare the 'xfiles' fixture parameter to read an xfile for the test function."},"warnings":[{"fix":"Consider alternative fixtures or pin pytest version.","message":"pytest-xfiles has not been updated since 2016; may not work with newer pytest versions (>5).","severity":"deprecated","affected_versions":"0.2.0"},{"fix":"Use xfiles() to read the content, not just reference the fixture.","message":"The xfiles fixture returns a function, not the file content directly. You must call it.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure xfile follows the naming pattern: test_func.xfile or test_func/*.xfile.","message":"Xfile naming convention expects specific file extensions and paths; deviation leads to FileNotFoundError.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Install with 'pip install pytest-xfiles' and import with 'from pytest_xfiles import xfiles'.","cause":"The package is installed as 'pytest-xfiles' but Python import uses underscores.","error":"ModuleNotFoundError: No module named 'pytest_xfiles'"},{"fix":"Use the fixture name 'xfiles' as a test function parameter, not as import.","cause":"Incorrect import of entire module instead of the fixture.","error":"TypeError: 'module' object is not callable"},{"fix":"Check that the xfile path follows the pattern: test_<function>.xfile or test_<function>/<any>.xfile in the same directory.","cause":"Xfile not found in expected location or with wrong naming convention.","error":"FileNotFoundError: [Errno 2] No such file or directory"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}