小编Rez*_*eza的帖子

Python-当`new`参数不是DEFAULT时,为什么模拟补丁装饰器不会将模拟对象传递给测试函数

在 Python 3.6 中,我unittest.mock.patch用来修补这样的函数:

class SampleTest(TestCase):

    @mock.patch('some_module.f')
    def test_f(self, mocked_f):
        f()
        mocked_f.assert_called()

Run Code Online (Sandbox Code Playgroud)

This passes a mock.MagicMock() as mocked_f and everything works fine. However, when I want to use a custom mock object instead of the default mock.MagicMock() using new argument, the patch decorator does not pass the mocked object to the test_f method. Running this code will raise a TypeError:

class SampleTest(TestCase):

    @mock.patch('some_module.f', new=lambda: 8)
    def test_f(self, mocked_f):
        f()
        mocked_f.assert_called()
Run Code Online (Sandbox Code Playgroud)
TypeError: test_f() missing 1 required positional argument: …
Run Code Online (Sandbox Code Playgroud)

python python-mock python-unittest

8
推荐指数
2
解决办法
2342
查看次数

Gitlab Wiki-导入存储库时如何导入Wiki

我的服务器上运行了一个Gitlab CE 11.7 docker。当我从gitlab.com导入项目时,缺少其Wiki。我使用内置界面导入项目:

New Project > Import project [tab] > GitLab.com [button]

然后从连接到我的帐户的存储库列表中选择要导入的存储库。

有没有办法将存储库的Wiki从Gitlab.com迁移到GitLab CE实例?

import wiki gitlab gitlab-ce

0
推荐指数
2
解决办法
846
查看次数

标签 统计

gitlab ×1

gitlab-ce ×1

import ×1

python ×1

python-mock ×1

python-unittest ×1

wiki ×1