Skip to main content

TestSlide fixture for pytest.

Quickstart

Install:

pip install pytest-testslide

In your test file:

        import pytest
        from pytest_testslide import testslide
        from testslide import StrictMock # if you wish to use StrictMock
        from testslide import matchers # if you wish to use Rspec style argument matchers
        .....
        def test_mock_callable_patching_works(testslide):
            testslide.mock_callable(time, "sleep").to_raise(RuntimeError("Mocked!")) #mock_callable
            with pytest.raises(RuntimeError):
                time.sleep()

        @pytest.mark.asyncio
        async def test_mock_async_callable_patching_works(testslide):
            testslide.mock_async_callable(sample_module.ParentTarget, "async_static_method").to_raise(RuntimeError("Mocked!")) #mock_async_callable
            with pytest.raises(RuntimeError):
                await sample_module.ParentTarget.async_static_method("a", "b")

        def test_mock_constructor_patching_works(testslide):
            testslide.mock_constructor(sample_module, "ParentTarget").to_raise(RuntimeError("Mocked!"))  #mock_constructor
            with pytest.raises(RuntimeError):
                sample_module.ParentTarget()

        def test_patch_attribute_patching_works(testslide):
            testslide.patch_attribute(sample_module.SomeClass, "attribute", "patched") #patch_attribute
            assert sample_module.SomeClass.attribute == "patched"

Release files for pytest-testslide 2.6.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-testslide 2.6.3
File Size Uploaded
pytest-testslide-2.6.3.tar.gz 2.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-testslide 2.6.3
File Interpreter ABI Platform
pytest_testslide-2.6.3-py3-none-any.whl Python 3 none any Details

Total release size: 5.5 kB

Release files / pytest-testslide-2.6.3.tar.gz

Download URL pytest-testslide-2.6.3.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b412bbe37711f6e4263b55363286ebd5fe021fbef3bdfa1a4f4bce8723719568
BLAKE2b-256 checksum
How to use checksums
50b7238e73b7d946bfdabf9f484a5902fee52be6c304b2e1b63aa6c2df0192e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.7.5

Release files / pytest_testslide-2.6.3-py3-none-any.whl

Download URL pytest_testslide-2.6.3-py3-none-any.whl
Size 2.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4bbce871a66e204b8ac3750a4cca5ca1eec44dba45649fcbad14651e7083bfea
BLAKE2b-256 checksum
How to use checksums
f109760b5a7d9de98554918cdbedcc0ed2fab689aae9689290d330187757b34e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.7.5

Release history Release notifications | RSS feed

This release

2.6.3 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page