Skip to main content

TestSlide fixture for pytest

Project description

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"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-testslide-2.6.3.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

pytest_testslide-2.6.3-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file pytest-testslide-2.6.3.tar.gz.

File metadata

  • Download URL: pytest-testslide-2.6.3.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for pytest-testslide-2.6.3.tar.gz
Algorithm Hash digest
SHA256 b412bbe37711f6e4263b55363286ebd5fe021fbef3bdfa1a4f4bce8723719568
MD5 590fba2d2bf726e21e607a0bb3bc49dd
BLAKE2b-256 50b7238e73b7d946bfdabf9f484a5902fee52be6c304b2e1b63aa6c2df0192e5

See more details on using hashes here.

File details

Details for the file pytest_testslide-2.6.3-py3-none-any.whl.

File metadata

  • Download URL: pytest_testslide-2.6.3-py3-none-any.whl
  • Upload date:
  • Size: 2.8 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for pytest_testslide-2.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4bbce871a66e204b8ac3750a4cca5ca1eec44dba45649fcbad14651e7083bfea
MD5 bde0eb5c52c02d198029bf768a7754a3
BLAKE2b-256 f109760b5a7d9de98554918cdbedcc0ed2fab689aae9689290d330187757b34e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page