python Programming Glossary: mock
Executing Javascript from Python http://stackoverflow.com/questions/10136319/executing-javascript-from-python js.replace document.write return Or you could create a mock document object class MockDocument object def __init__ self..
How do I mock an open used in a with statement (using the Mock framework in Python)? http://stackoverflow.com/questions/1289894/how-do-i-mock-an-open-used-in-a-with-statement-using-the-mock-framework-in-pyth do I mock an open used in a with statement using the Mock framework in.. framework in Python How do I test the following code with mocks using mocks the patch decorator and sentinels provided by Michael.. Python How do I test the following code with mocks using mocks the patch decorator and sentinels provided by Michael Foord's..
python: How to add property to a class dynamically? http://stackoverflow.com/questions/1325673/python-how-to-add-property-to-a-class-dynamically property to a class dynamically The goal is to create a mock class which behaves like a db resultset. So for example if a..
Is `import module` better coding style than `from module import function`? http://stackoverflow.com/questions/1744258/is-import-module-better-coding-style-than-from-module-import-function on the following points mentioned here Pros for IM ease of mocking injecting in tests. I am not very familiar with mocking though.. of mocking injecting in tests. I am not very familiar with mocking though I recently learned what the term means. Can you show.. example to make testing repeatable FPIM pro point 1 you mock both seed and random in the random module and if your code follows..
Practicing BDD with python [closed] http://stackoverflow.com/questions/231371/practicing-bdd-with-python driven design I personally tend to use nose and voidspace mock in a behavior driven design style. Specifically the spec plugin..
How can one mock/stub python module like urllib http://stackoverflow.com/questions/295438/how-can-one-mock-stub-python-module-like-urllib can one mock stub python module like urllib I need to test a function that.. what urllib.urlopen returns python unit testing testing mocking share improve this question Another simple approach is..
Python: Trying to mock datetime.date.today() but not working http://stackoverflow.com/questions/4481954/python-trying-to-mock-datetime-date-today-but-not-working Trying to mock datetime.date.today but not working Can anyone tell me why.. working Can anyone tell me why this isn't working import mock @mock.patch 'datetime.date.today' ... def today cls ... return.. Can anyone tell me why this isn't working import mock @mock.patch 'datetime.date.today' ... def today cls ... return date..
What's the best SOAP library for Python 3.x? [closed] http://stackoverflow.com/questions/7817303/whats-the-best-soap-library-for-python-3-x of the service you could use ladon for the server side and mock up the client by hand until there's a better solution available...
How to mock an import http://stackoverflow.com/questions/8658043/how-to-mock-an-import to mock an import Module A includes import B at its top. However under.. B at its top. However under test conditions I'd like to mock B in A mock A.B and completely refrain from importing B . In.. top. However under test conditions I'd like to mock B in A mock A.B and completely refrain from importing B . In fact B isn't..
how is this Strategy Pattern written in Python? (the sample in Wikipedia) http://stackoverflow.com/questions/963965/how-is-this-strategy-pattern-written-in-python-the-sample-in-wikipedia example in Python is not so different of the others. To mock the PHP script class StrategyExample def __init__ self func..
What is your favorite Python mocking library? [closed] http://stackoverflow.com/questions/98053/what-is-your-favorite-python-mocking-library is your favorite Python mocking library closed What is your single favorite mocking library.. mocking library closed What is your single favorite mocking library for Python python mocking share improve this question.. is your single favorite mocking library for Python python mocking share improve this question I've only used one but I've..
How to Mock an HTTP request in a unit testing scenario in Python http://stackoverflow.com/questions/11399148/how-to-mock-an-http-request-in-a-unit-testing-scenario-in-python to Mock an HTTP request in a unit testing scenario in Python I would.. unit test. In particular have a look at the excellent Mock module . Simple unit test So if we have a look at your CssTests.. self.assertListEqual expected_urls css_urls Mocking with Dependency Injection Now something less obvious would..
How do I mock an open used in a with statement (using the Mock framework in Python)? http://stackoverflow.com/questions/1289894/how-do-i-mock-an-open-used-in-a-with-statement-using-the-mock-framework-in-pyth do I mock an open used in a with statement using the Mock framework in Python How do I test the following code with mocks.. patch decorator and sentinels provided by Michael Foord's Mock framework def testme filepath with open filepath 'r' as f return.. protocol methods magic methods particularly using the MagicMock http www.voidspace.org.uk python mock magicmock.html An example..
Why can't I pickle this object? http://stackoverflow.com/questions/2049849/why-cant-i-pickle-this-object mock filesystem object file open 'testpickle.dat' 'w' file Mock pickle.dump ins_change file I get Traceback most recent call.. will cause mysterious bugs one day the misuses of Mock that has already been noted the default use of the slowest grungiest..
In Python, what's a good pattern for disabling certain code during unit tests? http://stackoverflow.com/questions/2320210/in-python-whats-a-good-pattern-for-disabling-certain-code-during-unit-tests share improve this question Use Michael Foord's Mock in your unit test do this from mock import Mock class Person.. Foord's Mock in your unit test do this from mock import Mock class Person object def __init__ self name super Person self.. Bob #now mock all of person's methods attributes person Mock spec person #talkto is some function you are testing talkTo..
Assert that a method was called in a Python unit test http://stackoverflow.com/questions/3829742/assert-that-a-method-was-called-in-a-python-unit-test python unit testing share improve this question I use Mock for this from mock import patch from PyQt4 import Qt @patch.object.. 42 # or mock.assert_called_once_with 42 Mock supports quite a few useful features including ways to patch..
Python: Trying to mock datetime.date.today() but not working http://stackoverflow.com/questions/4481954/python-trying-to-mock-datetime-date-today-but-not-working function class in this case datetime.date.today with a Mock object only within the decorated function . So only within your..
unittest colored output http://stackoverflow.com/questions/5203633/unittest-colored-output actually unittest2 for Python testing together with Python Mock for mocking objects and nose to run all tests in a single pass...
Mocking a class: Mock() or patch()? http://stackoverflow.com/questions/8180769/mocking-a-class-mock-or-patch a class Mock or patch I am using mock with Python and was.. a class Mock or patch I am using mock with Python and was wondering which.. and use that. The code looks like def test_one self mock Mock mock.method.return_value True self.sut.something mock # This..
How to mock an import http://stackoverflow.com/questions/8658043/how-to-mock-an-import actual functions variables etc. Or you can just assign a Mock directly test.py import sys sys.modules 'B' Mock import A ..
What is your favorite Python mocking library? [closed] http://stackoverflow.com/questions/98053/what-is-your-favorite-python-mocking-library used one but I've had good results with Michael Foord's Mock http www.voidspace.org.uk python mock . Michael's introduction..
|