Interested in buying ad space on this blog?
You can, on BuySellAds.com

Do you train Kung Fu?
Or know someone who does?
Then check out KungFuPeople.com
Mobile version of this page|
You searched for keyword:mocking |
found 0 photos and 2 blogs in and 0 blog comments in 0.00 seconds |
Blogs |
|
|
|
Mocking os.stat in Python - 8th of November 2009 I have some code that checks that a file is treated differently if some time has passed. In other words, it reacts if the modification time is more than it was before. The code uses def test_file_changed(self):
filename = 'foo.txt' expect_timestamp = int(time.time()) ...run the unit test with 'expect_timestamp'... time.sleep(1) expect_timestamp += 1 ...run the unit test with 'expect_timestamp'... |
|
|
Mocking a Python standard library - 14th of March 2008 Here's one of many things I've learnt today at PyCon. Inspired by code that Grig Gheorghiu showed in his slides on automated testing, you can monkey patch a standard library that your application is using in your unit tests to, in my case, mock a remote service without having to run a server. I've done lots of monkey-patching in Zope but then I've only been monkey patching individual methods or attributes of imported classes. This is very similar to that. Here's what my application does:
from poplib import POP3
class MyZopeApp(...): def check4mail(self, hostname, port, user, pwd): connection = POP3(hostname, port=port) ...download emails and process them... |

