Coder Social home page Coder Social logo

egor43 / pytest-mock Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pytest-dev/pytest-mock

0.0 0.0 0.0 421 KB

Thin-wrapper around the mock package for easier use with pytest

Home Page: https://pytest-mock.readthedocs.io/en/latest/

License: MIT License

Python 100.00%

pytest-mock's Introduction

pytest-mock

This plugin provides a mocker fixture which is a thin-wrapper around the patching API provided by the mock package:

import os

class UnixFS:

    @staticmethod
    def rm(filename):
        os.remove(filename)

def test_unix_fs(mocker):
    mocker.patch('os.remove')
    UnixFS.rm('file')
    os.remove.assert_called_once_with('file')

Besides undoing the mocking automatically after the end of the test, it also provides other nice utilities such as spy and stub, and uses pytest introspection when comparing calls.

python version anaconda docs ci coverage black pre-commit

Professionally supported pytest-mock is available.

Documentation

For full documentation, please see https://pytest-mock.readthedocs.io/en/latest.

License

Distributed under the terms of the MIT license.

pytest-mock's People

Contributors

nicoddemus avatar pre-commit-ci[bot] avatar hugovk avatar blueyed avatar inderpreet99 avatar fogo avatar jurko-gospodnetic avatar tirkarthi avatar graingert avatar the-compiler avatar jhermann avatar tigarmo avatar webknjaz avatar asfaltboy avatar plannigan avatar kjwilcox avatar cclauss avatar rouge8 avatar alexgascon avatar yesthesoup avatar shadycuz avatar mgorny avatar attomos avatar niccolum avatar scorphus avatar perchunpak avatar ronnypfannschmidt avatar sgaist avatar srittau avatar sobolevn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.