当前位置: 首页>>代码示例>>Python>>正文


Python mock.call函数代码示例

本文整理汇总了Python中tests.support.mock.call函数的典型用法代码示例。如果您正苦于以下问题:Python call函数的具体用法?Python call怎么用?Python call使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了call函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_display

 def test_display(self, call):
     for action in self.actions:
         self.display.progress(self.pkg, action, 0, 100, 1, 1000)
         msg = self.display._fmt_event(self.pkg, action, 1, 1000)
         # updating plymouth display means two plymouth calls
         call.assert_has_calls([
             mock.call((PLYMOUTH, "system-update", "--progress", "0")),
             mock.call((PLYMOUTH, "display-message", "--text", msg))
         ], any_order=True)
开发者ID:rpm-software-management,项目名称:dnf-plugins-extras,代码行数:9,代码来源:test_system_upgrade.py

示例2: test_setup_from_dnf_conf

 def test_setup_from_dnf_conf(self, setup_m):
     conf = mock.Mock(debuglevel=2, errorlevel=2, logdir=self.logdir)
     self.logging._setup_from_dnf_conf(conf)
     self.assertEqual(setup_m.call_args, mock.call(dnf.logging.INFO,
                                                   dnf.logging.WARNING,
                                                   self.logdir))
     conf = mock.Mock(debuglevel=6, errorlevel=6, logdir=self.logdir)
     self.logging._setup_from_dnf_conf(conf)
     self.assertEqual(setup_m.call_args, mock.call(dnf.logging.DEBUG,
                                                   dnf.logging.WARNING,
                                                   self.logdir))
开发者ID:dmach,项目名称:dnf,代码行数:11,代码来源:test_logging.py

示例3: test_filter_calls

    def test_filter_calls(self, call):
        action = PKG_INSTALL
        # first display update -> set percentage and text
        self.display.progress(self.pkg, action, 0, 100, 1, 1000)
        msg1 = self.display._fmt_event(self.pkg, action, 1, 1000)
        call.assert_has_calls([
            mock.call((PLYMOUTH, "system-update", "--progress", "0")),
            mock.call((PLYMOUTH, "display-message", "--text", msg1)),
        ])

        # event progress on the same transaction item.
        # no new calls to plymouth because the percentage and text don't change
        for te_cur in range(1, 100):
            self.display.progress(self.pkg, action, te_cur, 100, 1, 1000)
        call.assert_has_calls([
            mock.call((PLYMOUTH, "system-update", "--progress", "0")),
            mock.call((PLYMOUTH, "display-message", "--text", msg1)),
        ])

        # new item: new message ("[2/1000] ..."), but percentage still 0..
        self.display.progress(self.pkg, action, 0, 100, 2, 1000)
        # old message hidden, new message displayed. no new percentage.
        msg2 = self.display._fmt_event(self.pkg, action, 2, 1000)
        call.assert_has_calls([
            mock.call((PLYMOUTH, "system-update", "--progress", "0")),
            mock.call((PLYMOUTH, "display-message", "--text", msg1)),
            mock.call((PLYMOUTH, "hide-message", "--text", msg1)),
            mock.call((PLYMOUTH, "display-message", "--text", msg2)),
        ])
开发者ID:rpm-software-management,项目名称:dnf-plugins-extras,代码行数:29,代码来源:test_system_upgrade.py

示例4: test_userconfirm

    def test_userconfirm(self, input_fnc):
        # with defaultyes==False
        input_fnc.return_value = 'y'
        self.assertTrue(self.output.userconfirm())
        self.assertEqual(input_fnc.call_args, mock.call(u'Is this ok [y/N]: '))

        input_fnc.return_value = 'n'
        self.assertFalse(self.output.userconfirm())

        input_fnc.return_value = ''
        self.assertFalse(self.output.userconfirm())

        input_fnc.side_effect = self._keyboard_interrupt
        input_fnc.return_value = 'y'
        self.assertFalse(self.output.userconfirm())

        input_fnc.side_effect = self._eof_error
        self.assertFalse(self.output.userconfirm())

        # with defaultyes==True
        self.output.conf.defaultyes = True
        input_fnc.side_effect = None
        input_fnc.return_value = ''
        self.assertTrue(self.output.userconfirm())

        input_fnc.side_effect = self._keyboard_interrupt
        input_fnc.return_value = ''
        self.assertFalse(self.output.userconfirm())

        input_fnc.side_effect = self._eof_error
        self.assertTrue(self.output.userconfirm())
开发者ID:DNIWE-Systems,项目名称:dnf,代码行数:31,代码来源:test_output.py

示例5: test_downgradePkgs_notinstalled

    def test_downgradePkgs_notinstalled(self, logger):
        tests.support.ObjectMatcher(dnf.package.Package, {'name': 'lotus'})

        with self.assertRaises(dnf.exceptions.Error) as ctx:
            self.base.downgradePkgs(('lotus',))
        self.assertEqual(str(ctx.exception), 'No packages marked for downgrade.')

        self.assertEqual(self.base.downgrade_to.mock_calls, [mock.call('lotus', strict=False)])
开发者ID:rpm-software-management,项目名称:dnf,代码行数:8,代码来源:test_cli.py

示例6: test_close

    def test_close(self):
        """Test close."""
        yum_history = mock.create_autospec(dnf.yum.history.YumHistory)
        history = self._create_wrapper(yum_history)

        history.close()

        self.assertEqual(yum_history.close.mock_calls, [mock.call()])
开发者ID:MattSturgeon,项目名称:dnf,代码行数:8,代码来源:test_history.py

示例7: test_downgradePkgs_notinstalled

    def test_downgradePkgs_notinstalled(self):
        pkg = support.ObjectMatcher(dnf.package.Package, {"name": "lotus"})

        with self.assertRaises(dnf.exceptions.Error) as ctx:
            self._base.downgradePkgs(("lotus",))
        self.assertEqual(str(ctx.exception), "Nothing to do.")

        self.assertEqual(self._base.downgrade.mock_calls, [mock.call("lotus")])
        self.assertEqual(self._base.logger.mock_calls, [mock.call.info("No match for available package: %s", pkg)] * 2)
开发者ID:hutarova,项目名称:dnf,代码行数:9,代码来源:test_cli.py

示例8: test_downgradePkgs_notfound

    def test_downgradePkgs_notfound(self):
        with self.assertRaises(dnf.exceptions.Error) as ctx:
            self._base.downgradePkgs(("non-existent",))
        self.assertEqual(str(ctx.exception), "Nothing to do.")

        self.assertEqual(self._base.downgrade.mock_calls, [mock.call("non-existent")])
        self.assertEqual(
            self._base.logger.mock_calls, [mock.call.info("No package %s%s%s available.", "", "non-existent", "")]
        )
开发者ID:hutarova,项目名称:dnf,代码行数:9,代码来源:test_cli.py

示例9: test_downgradePkgs_notfound

    def test_downgradePkgs_notfound(self, logger):
        with self.assertRaises(dnf.exceptions.Error) as ctx:
            self._base.downgradePkgs(('non-existent',))
        self.assertEqual(str(ctx.exception), 'Nothing to do.')

        self.assertEqual(self._base.downgrade.mock_calls,
                         [mock.call('non-existent')])
        self.assertEqual(logger.mock_calls,
                         [mock.call.info('No package %s%s%s available.', '',
                                         'non-existent', '')])
开发者ID:IMFTC,项目名称:dnf,代码行数:10,代码来源:test_cli.py

示例10: test_downgradePkgs_notinstalled

    def test_downgradePkgs_notinstalled(self, logger):
        pkg = support.ObjectMatcher(dnf.package.Package, {'name': 'lotus'})

        with self.assertRaises(dnf.exceptions.Error) as ctx:
            self._base.downgradePkgs(('lotus',))
        self.assertEqual(str(ctx.exception), 'Nothing to do.')

        self.assertEqual(self._base.downgrade_to.mock_calls, [mock.call('lotus')])
        self.assertEqual(logger.mock_calls, [
            mock.call.info('No match for available package: %s', pkg)] * 2)
开发者ID:MattSturgeon,项目名称:dnf,代码行数:10,代码来源:test_cli.py

示例11: test_update_not_installed

 def test_update_not_installed(self, logger):
     """ Updating an uninstalled package is a not valid operation. """
     self.base._goal = goal = mock.create_autospec(dnf.goal.Goal)
     # no "mrkite" installed:
     with self.assertRaises(dnf.exceptions.MarkingError) as context:
         self.base.upgrade("mrkite")
     self.assertEqual(logger.mock_calls, [
         mock.call(u'Package %s available, but not installed.', u'mrkite')])
     self.assertEqual(context.exception.pkg_spec, 'mrkite')
     self.assertEqual(goal.mock_calls, [])
开发者ID:mavit,项目名称:dnf,代码行数:10,代码来源:test_update.py

示例12: test_context_manager

    def test_context_manager(self):
        """Test whether _HistoryWrapper can be used as a context manager."""
        yum_history = mock.create_autospec(dnf.yum.history.YumHistory)
        history = self._create_wrapper(yum_history)

        with history as instance:
            pass

        self.assertIs(instance, history)
        self.assertEqual(yum_history.close.mock_calls, [mock.call()])
开发者ID:MattSturgeon,项目名称:dnf,代码行数:10,代码来源:test_history.py

示例13: test_downgradePkgs_notfound

    def test_downgradePkgs_notfound(self, logger):
        with self.assertRaises(dnf.exceptions.Error) as ctx:
            self.base.downgradePkgs(('non-existent',))
        self.assertEqual(str(ctx.exception), 'No packages marked for downgrade.')

        self.assertEqual(self.base.downgrade_to.mock_calls,
                         [mock.call('non-existent', strict=False)])
        self.assertEqual(logger.mock_calls,
                         [mock.call.info('No package %s available.',
                                         'non-existent')])
开发者ID:rpm-software-management,项目名称:dnf,代码行数:10,代码来源:test_cli.py

示例14: hidem

 def hidem(m):
     return mock.call((PLYMOUTH, "hide-message", "--text", m))
开发者ID:rpm-software-management,项目名称:dnf-plugins-extras,代码行数:2,代码来源:test_system_upgrade.py

示例15: dispm

 def dispm(m):
     return mock.call((PLYMOUTH, "display-message", "--text", m))
开发者ID:rpm-software-management,项目名称:dnf-plugins-extras,代码行数:2,代码来源:test_system_upgrade.py


注:本文中的tests.support.mock.call函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。