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


Python MagicMock.metric_source_name方法代码示例

本文整理汇总了Python中unittest.mock.MagicMock.metric_source_name方法的典型用法代码示例。如果您正苦于以下问题:Python MagicMock.metric_source_name方法的具体用法?Python MagicMock.metric_source_name怎么用?Python MagicMock.metric_source_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unittest.mock.MagicMock的用法示例。


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

示例1: test_format_text_with_links

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import metric_source_name [as 别名]
    def test_format_text_with_links(self, mock_metric_source_urls):
        """ Test that comment formatting function is the same as the text formatting one."""
        mock_metric_source_urls.return_value = ['http://url1']
        mock_metric_source = MagicMock()
        mock_metric_source.metric_source_name = "Text"
        project = MagicMock()
        project.metric_sources.return_value = [mock_metric_source]
        test_metric = domain.Metric(subject=MagicMock(), project=project)

        self.assertEqual("Some text... [{'href': 'http://url1', 'text': 'Text'}]",
                         test_metric.format_text_with_links('Some text...'))
开发者ID:ICTU,项目名称:quality-report,代码行数:13,代码来源:metric_tests.py

示例2: test_url_from_metric_source_urls

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import metric_source_name [as 别名]
    def test_url_from_metric_source_urls(self):
        """ Test metric url when there is no source id. """
        mock_metric_source = MagicMock()
        mock_metric_source.metric_source_urls.return_value = ['http://url!']
        mock_metric_source.metric_source_name = "Text"
        subject = MagicMock()
        subject.metric_source_id.return_value = "MsId"
        project = MagicMock()
        project.metric_sources.return_value = [mock_metric_source]
        test_metric = domain.Metric(subject=subject, project=project)

        self.assertEqual({"Text": 'http://url!'}, test_metric.url())
开发者ID:ICTU,项目名称:quality-report,代码行数:14,代码来源:metric_tests.py

示例3: test_url_two_sources

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import metric_source_name [as 别名]
    def test_url_two_sources(self):
        """ Test metric url when there are two metric source ids. """
        mock_metric_source = MagicMock()
        mock_metric_source.metric_source_urls.return_value = ['http:/url1', 'http:/url2']
        mock_metric_source.metric_source_name = "Text"
        subject = MagicMock()
        subject.metric_source_id.return_value = "MsId"
        project = MagicMock()
        project.metric_sources.return_value = [mock_metric_source]
        test_metric = domain.Metric(subject=subject, project=project)

        self.assertEqual({"Text (1/2)": "http:/url1", "Text (2/2)": "http:/url2"}, test_metric.url())
开发者ID:ICTU,项目名称:quality-report,代码行数:14,代码来源:metric_tests.py

示例4: test_url_metric_source_different_display_two_links

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import metric_source_name [as 别名]
    def test_url_metric_source_different_display_two_links(self):
        """ Test metric url when there are two links - one with a display link and the other without. """
        mock_metric_source = MagicMock()
        mock_metric_source.metric_source_urls.return_value = ["metric source url"]
        mock_metric_source.metric_source_name = "Text"

        subject = MagicMock()
        subject.metric_source_id.return_value = [{"source": 'http:\\link', "display": 'http:\\display.url'}, "simple"]
        project = MagicMock()
        project.metric_sources.return_value = [mock_metric_source]
        test_metric = domain.Metric(subject=subject, project=project)

        self.assertEqual({"Text": "metric source url"}, test_metric.url())
        mock_metric_source.metric_source_urls.assert_called_once_with('http:\\display.url', "simple")
开发者ID:ICTU,项目名称:quality-report,代码行数:16,代码来源:metric_tests.py

示例5: test_url_metric_source_different_display

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import metric_source_name [as 别名]
    def test_url_metric_source_different_display(self):
        """ Test metric url when there is a display link. """
        mock_metric_source = MagicMock()
        mock_metric_source.metric_source_urls.return_value = ["metric source url"]
        mock_metric_source.metric_source_name = "Text"

        subject = MagicMock()
        subject.metric_source_id.return_value = {"source": 'http:\\link', "display": 'http:\\display.url'}
        project = MagicMock()
        project.metric_sources.return_value = [mock_metric_source]
        test_metric = domain.Metric(subject=subject, project=project)

        self.assertEqual({"Text": "metric source url"}, test_metric.url())
        mock_metric_source.metric_source_urls.assert_called_once_with('http:\\display.url')
开发者ID:ICTU,项目名称:quality-report,代码行数:16,代码来源:metric_tests.py

示例6: test_url_metric_source_different_metric_source_urls

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import metric_source_name [as 别名]
    def test_url_metric_source_different_metric_source_urls(self):
        """ Test metric url when there are metric source urls. """
        mock_metric_source = MagicMock()
        mock_metric_source.metric_source_urls.return_value = ["metric source url"]
        mock_metric_source.metric_source_name = "Text"

        subject = MagicMock()
        subject.metric_source_id.return_value = "MsId"
        project = MagicMock()
        project.metric_sources.return_value = [mock_metric_source]
        test_metric = domain.Metric(subject=subject, project=project)

        self.assertEqual({"Text": "metric source url"}, test_metric.url())
        mock_metric_source.metric_source_urls.assert_called_once_with('MsId')
开发者ID:ICTU,项目名称:quality-report,代码行数:16,代码来源:metric_tests.py


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