How do I unit test a module that relies on urllib2?

前端 未结 7 1240
孤街浪徒
孤街浪徒 2020-12-08 05:16

I\'ve got a piece of code that I can\'t figure out how to unit test! The module pulls content from external XML feeds (twitter, flickr, youtube, etc.) with urllib2. Here\'s

7条回答
  •  没有蜡笔的小新
    2020-12-08 05:19

    You can use pymox to mock the behavior of anything and everything in the urllib2 (or any other) package. It's 2010, you shouldn't be writing your own mock classes.

提交回复
热议问题