资讯专栏INFORMATION COLUMN

[gist]Evernote with emacs and org-mode

susheng / 2605人阅读

摘要:最近在用和为应用测试发现几个使用要注意的地方一个导入的因为已经被导入到目标文件因此必须要目标文件的该方法而不是原

from http://oyanglul.us

最近在用 nosetests 和 mock1 为 bottle 应用测试, 发现几个使用nosetests 要注意的 地方:

1 patch method of module

patch 一个导入 module 的 method, 因为 method 已经被导入到目标文件, 因此必须 要 patch 目标文件的 该方法, 而不是原 module.

# wsgi.py
from db import get_db

def insert_something():
    get_db().insert(something)

# test.py
import wsgi

# @patch("db.get_db") # this won"t work
@patch("wsgi.get_db") # should patch wsgi
def test_insert(mock_get_db):
    mock_get_db.return_value = Database()
    ...

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/85257.html

相关文章

  • [gist]Why do we still need Evernote since there is

    from http://oyanglul.us Im a Emacs user and as you may know there is a awesome mode called gist.el, and since then, I found that its completely...

    philadelphia 评论0 收藏0
  • 【转】给年轻的前端程序员提升能力的几条建议

    摘要:如果你问一个年轻的前端开发人员,你在今后的年内如何提升自己的能力他可能会说我现在对前端比较熟悉,但我想深入了解,另外现在发展的很快我也想看一下。再举一个例子,我会留意身边的程序员所用的键盘。只有少部分的程序员会买高端的静电容键盘,比如。 如果你问一个年轻的前端开发人员,你在今后的 3 年内如何提升自己的能力?他可能会说我现在对 Web 前端比较熟悉,但我想深入了解 AngularJS,...

    Ryan_Li 评论0 收藏0
  • [gist]emacs auto config

    摘要:有同学问初学该有个什么之类的虽然我之前也在用但是那玩意其实对来说已经很鸡肋了对包管理这块做的已经足够好而且源也足够多因此配置会变得容易的多我也不知道在哪翻出来的这个正好同时解决了新手配置以及文档化的问题所以我决定从迁过 from http://oyanglul.us 有同学...

    aervon 评论0 收藏0
  • [gist]pure and secure javascript oauth with yql

    from http://oyanglul.us It would be awesome if we can use OAuth in JavaScript purely in client side. before start to do that, please let me e...

    ityouknow 评论0 收藏0

发表评论

0条评论

susheng

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<