{"id":22455,"library":"testslide","title":"TestSlide","description":"A test framework for Python that makes mocking and iterating over code with tests a breeze. Current version 2.7.1 (2022). Release cadence is irregular.","status":"active","version":"2.7.1","language":"python","source_language":"en","source_url":"https://github.com/facebook/TestSlide","tags":["testing","mocking","facebook","test-framework"],"install":[{"cmd":"pip install testslide","lang":"bash","label":"PyPI"}],"dependencies":[],"imports":[{"note":"Case-sensitive module name.","wrong":"from TestSlide import TestSlideTestCase","symbol":"TestSlideTestCase","correct":"from testslide import TestSlideTestCase"},{"note":"mock_callable is a top-level import.","wrong":"from testslide.mock import mock_callable","symbol":"mock_callable","correct":"from testslide import mock_callable"},{"note":"StrictMock is directly under testslide.","wrong":"from testslide.mock import StrictMock","symbol":"StrictMock","correct":"from testslide import StrictMock"},{"note":"MockAttribute is available from testslide.","wrong":"from testslide.mock import MockAttribute","symbol":"MockAttribute","correct":"from testslide import MockAttribute"},{"note":"patch_any is in testslide.mock submodule.","wrong":"from testslide import patch_any","symbol":"patch_any","correct":"from testslide.mock import patch_any"}],"quickstart":{"code":"import testslide\n\ndef test_example(testslide_context):\n    mock = testslide.mock_callable('os.getcwd')\n    mock.to_return('/mock/path')\n    assert os.getcwd() == '/mock/path'\n","lang":"python","description":"Basic mocking example using TestSlide."},"warnings":[{"fix":"Use the exact dotted string as imported in the module under test.","message":"TestSlide's mock_callable patches functions by string name (e.g., 'os.getcwd'), not by object reference. Ensure the string matches the import path used in the code under test.","severity":"gotcha","affected_versions":"all"},{"fix":"Define test functions with an extra parameter named `testslide_context` or use the context manager.","message":"TestSlide uses a context-based approach: tests must accept a `testslide_context` parameter or use `with testslide.Context(...)`.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `mock.to_return(...)` or `mock.to_raise(...)` for expected attributes.","message":"StrictMock raises AttributeError on access to unexpected attributes. This is by design but can be surprising if you misspell an attribute.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `from testslide import TestSlideTestCase`.","cause":"Incorrect import casing: using `TestSlide` instead of `testslide`.","error":"AttributeError: 'module' object has no attribute 'TestSlideTestCase'"},{"fix":"Add `testslide_context` parameter to your test function: `def test_foo(testslide_context):`.","cause":"Missing `testslide_context` parameter in test function.","error":"TypeError: 'Context' object is not callable"},{"fix":"Ensure you use `mock.to_return(...)` after `mock = testslide.mock_callable('...')`.","cause":"Typo: using `to_return` instead of `to_return`? Actually correct method is `to_return`. Check if you used `mock_callable` correctly.","error":"AttributeError: MockCallable object has no attribute 'to_return'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}