• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python assertions.assert_in函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_build_action_run_collection

 def test_build_action_run_collection(self):
     collection = ActionRunFactory.build_action_run_collection(self.job_run)
     assert_equal(collection.action_graph, self.action_graph)
     assert_in('act1', collection.run_map)
     assert_in('act2', collection.run_map)
     assert_length(collection.run_map, 2)
     assert_equal(collection.run_map['act1'].action_name, 'act1')
开发者ID:Bklyn,项目名称:Tron,代码行数:7,代码来源:actionrun_test.py


示例2: test_deprecated_msg_param

    def test_deprecated_msg_param(self):
        with warnings.catch_warnings(record=True) as w:
            assertions.assert_is_not(False, None, msg="This is a message")

            assertions.assert_equal(len(w), 1)
            assert issubclass(w[-1].category, DeprecationWarning)
            assertions.assert_in("msg is deprecated", str(w[-1].message))
开发者ID:pyarnold,项目名称:Testify,代码行数:7,代码来源:assertions_test.py


示例3: test_proxy_list

 def test_proxy_list(self):
     the_list = range(3)
     validator = mock.Mock(return_value=the_list)
     value_proxy = proxy.ValueProxy(validator, self.value_cache, 'the_list')
     assert_equal(value_proxy, the_list)
     assert_in(2, value_proxy)
     assert_equal(value_proxy[:1], [0])
     assert_equal(len(value_proxy), 3)
开发者ID:analogue,项目名称:PyStaticConfiguration,代码行数:8,代码来源:proxy_test.py


示例4: test_check_if_pidfile_exists_file_exists

    def test_check_if_pidfile_exists_file_exists(self):
        self.pidfile.__exit__(None, None, None)
        with open(self.filename, 'w') as fh:
            fh.write('123\n')

        with mock.patch.object(PIDFile, 'is_process_running') as mock_method:
            mock_method.return_value = True
            exception = assert_raises(SystemExit, PIDFile, self.filename)
            assert_in('Daemon running as 123', str(exception))
开发者ID:Codeacious,项目名称:Tron,代码行数:9,代码来源:trondaemon_test.py


示例5: test_build_getter

 def test_build_getter(self):
     validator = mock.Mock()
     getter = getters.build_getter(validator)
     assert callable(getter), "Getter is not callable"
     value_proxy = getter('the_name')
     namespace = config.get_namespace(config.DEFAULT)
     assert_in(id(value_proxy), namespace.value_proxies)
     assert_equal(value_proxy.config_key, "the_name")
     assert_equal(value_proxy.namespace, namespace)
开发者ID:analogue,项目名称:PyStaticConfiguration,代码行数:9,代码来源:getters_test.py


示例6: test_build_new_run_manual

 def test_build_new_run_manual(self):
     autospec_method(self.run_collection.remove_old_runs)
     run_time = datetime.datetime(2012, 3, 14, 15, 9, 26)
     mock_job = build_mock_job()
     job_run = self.run_collection.build_new_run(
         mock_job, run_time, self.mock_node, True)
     assert_in(job_run, self.run_collection.runs)
     self.run_collection.remove_old_runs.assert_called_with()
     assert_equal(job_run.run_num, 5)
     assert job_run.manual
开发者ID:ContextLogic,项目名称:Tron,代码行数:10,代码来源:jobrun_test.py


示例7: test_client_returns_zero_on_success

 def test_client_returns_zero_on_success(self):
     server_process = subprocess.Popen(
         ["python", "-m", "testify.test_program", "testing_suite.example_test", "--serve", "9001"],
         stdout=open(os.devnull, "w"),
         stderr=open(os.devnull, "w"),
     )
     # test_call has the side-effect of asserting the return code is 0
     ret = test_call(["python", "-m", "testify.test_program", "--connect", "localhost:9001"])
     assert_in("PASSED", ret)
     assert_equal(server_process.wait(), 0)
开发者ID:bukzor,项目名称:Testify,代码行数:10,代码来源:test_program_test.py


示例8: test_build_getter_with_getter_namespace

 def test_build_getter_with_getter_namespace(self):
     validator = mock.Mock()
     name = 'the stars'
     getter = getters.build_getter(validator, getter_namespace=name)
     assert callable(getter), "Getter is not callable"
     value_proxy = getter('the_name')
     namespace = config.get_namespace(name)
     assert_in(id(value_proxy), namespace.value_proxies)
     assert_equal(value_proxy.config_key, "the_name")
     assert_equal(value_proxy.namespace, namespace)
开发者ID:analogue,项目名称:PyStaticConfiguration,代码行数:10,代码来源:getters_test.py


示例9: test_restore_state

 def test_restore_state(self):
     count = 3
     state_data = [dict(instance_number=i * 3, node="node") for i in xrange(count)]
     autospec_method(self.collection._build_instance)
     created = self.collection.restore_state(state_data)
     assert_length(created, count)
     assert_equal(set(created), set(self.collection.instances))
     expected = [mock.call(self.node_pool.get_by_hostname.return_value, d["instance_number"]) for d in state_data]
     for expected_call in expected:
         assert_in(expected_call, self.collection._build_instance.mock_calls)
开发者ID:jabadie-iseatz,项目名称:Tron,代码行数:10,代码来源:serviceinstance_test.py


示例10: test_rerun_with_failure_limit

 def test_rerun_with_failure_limit(self):
     proc = subprocess.Popen(
         (sys.executable, "-m", "testify.test_program", "--rerun-test-file=/dev/stdin", "--failure-limit", "1"),
         stdin=subprocess.PIPE,
         stdout=subprocess.PIPE,
     )
     stdout, _ = proc.communicate(
         b"test.fails_two_tests FailsTwoTests.test1\n" b"test.fails_two_tests FailsTwoTests.test2\n"
     )
     assert_in(b"FAILED.  1 test / 1 case: 0 passed, 1 failed.", stdout)
开发者ID:chunkyg,项目名称:Testify,代码行数:10,代码来源:test_program_test.py


示例11: test__str__

 def test__str__(self):
     self.collection._is_run_blocked = lambda r: r.action_name != 'cleanup'
     expected = [
         "ActionRunCollection",
         "second_name(scheduled:blocked)",
         "action_name(scheduled:blocked)",
         "cleanup(scheduled)"
     ]
     for expectation in expected:
         assert_in(expectation, str(self.collection))
开发者ID:Codeacious,项目名称:Tron,代码行数:10,代码来源:actionrun_test.py


示例12: test_getters

    def test_getters(self):
        get_conf = getters.NamespaceGetters(self.namespace)
        proxies = [
            get_conf.get_bool('is_it'),
            get_conf.get_time('when'),
            get_conf.get_list_of_bool('options')
        ]

        namespace = config.get_namespace(get_conf.namespace)
        for proxy in proxies:
            assert_in(id(proxy), namespace.value_proxies)
开发者ID:analogue,项目名称:PyStaticConfiguration,代码行数:11,代码来源:getters_test.py


示例13: test_build_new_run_manual

 def test_build_new_run_manual(self):
     self.run_collection.remove_old_runs = Turtle()
     run_time = datetime.datetime(2012, 3, 14, 15, 9, 26)
     job = Turtle(name="thejob")
     job.action_graph.action_map = {}
     node = MockNode("thenode")
     job_run = self.run_collection.build_new_run(job, run_time, node, True)
     assert_in(job_run, self.run_collection.runs)
     assert_call(self.run_collection.remove_old_runs, 0)
     assert_equal(job_run.run_num, 5)
     assert job_run.manual
开发者ID:Bklyn,项目名称:Tron,代码行数:11,代码来源:jobrun_test.py


示例14: test_rerun_with_failure_limit

 def test_rerun_with_failure_limit(self):
     proc = subprocess.Popen(
         (
             sys.executable, '-m', 'testify.test_program',
             '--rerun-test-file=/dev/stdin',
             '--failure-limit', '1',
         ),
         stdin=subprocess.PIPE,
         stdout=subprocess.PIPE,
     )
     stdout, _ = proc.communicate(
         b'test.fails_two_tests FailsTwoTests.test1\n'
         b'test.fails_two_tests FailsTwoTests.test2\n'
     )
     assert_in(b'FAILED.  1 test / 1 case: 0 passed, 1 failed.', stdout)
开发者ID:Yelp,项目名称:Testify,代码行数:15,代码来源:test_program_test.py


示例15: test_end_to_end_basic

    def test_end_to_end_basic(self):
        self.start_with_config(SINGLE_ECHO_CONFIG)
        client = self.sandbox.client

        assert_equal(self.client.config('MASTER')['config'], SINGLE_ECHO_CONFIG)

        # reconfigure and confirm results
        second_config = DOUBLE_ECHO_CONFIG + TOUCH_CLEANUP_FMT
        self.sandbox.tronfig(second_config)
        events = summarize_events(client.events())
        assert_in(('', 'restoring'), events)
        assert_in(('MASTER.echo_job.0', 'created'), events)
        assert_equal(client.config('MASTER')['config'], second_config)

        # reconfigure, by uploading a third configuration
        self.sandbox.tronfig(ALT_NAMESPACED_ECHO_CONFIG, name='ohce')
        self.sandbox.client.home()

        # run the job and check its output
        echo_job_name = 'MASTER.echo_job'
        job_url = client.get_url(echo_job_name)
        action_url = client.get_url('MASTER.echo_job.1.echo_action')

        self.sandbox.tronctl('start', echo_job_name)

        def wait_on_cleanup():
            return (len(client.job(job_url)['runs']) >= 2 and
                    client.action_runs(action_url)['state'] ==
                    actionrun.ActionRun.STATE_SUCCEEDED.name)
        sandbox.wait_on_sandbox(wait_on_cleanup)

        echo_action_run = client.action_runs(action_url)
        another_action_url = client.get_url('MASTER.echo_job.1.another_echo_action')
        other_act_run = client.action_runs(another_action_url)
        assert_equal(echo_action_run['state'],
            actionrun.ActionRun.STATE_SUCCEEDED.name)
        assert_equal(echo_action_run['stdout'], ['Echo!'])
        assert_equal(other_act_run['state'],
            actionrun.ActionRun.STATE_FAILED.name)

        now = datetime.datetime.now()
        stdout = now.strftime('Today is %Y-%m-%d, which is the same as %Y-%m-%d')
        assert_equal(other_act_run['stdout'], [stdout])

        job_runs_url = client.get_url('%s.1' % echo_job_name)
        assert_equal(client.job_runs(job_runs_url)['state'],
            actionrun.ActionRun.STATE_FAILED.name)
开发者ID:Codeacious,项目名称:Tron,代码行数:47,代码来源:trond_test.py


示例16: test_client_returns_zero_on_success

 def test_client_returns_zero_on_success(self):
     server_process = subprocess.Popen(
         [
             'python', '-m', 'testify.test_program',
             'testing_suite.example_test',
             '--serve', '9001',
         ],
         stdout=open(os.devnull, 'w'),
         stderr=open(os.devnull, 'w'),
     )
     # test_call has the side-effect of asserting the return code is 0
     ret = test_call([
         'python', '-m', 'testify.test_program',
         '--connect', 'localhost:9001',
     ])
     assert_in('PASSED', ret)
     assert_equal(server_process.wait(), 0)
开发者ID:pyarnold,项目名称:Testify,代码行数:17,代码来源:test_program_test.py


示例17: test_service_failed_restart

    def test_service_failed_restart(self):
        config = BASIC_CONFIG + dedent("""
            services:
                -   name: service_restart
                    node: local
                    pid_file: "/tmp/file_dne"
                    command: "sleep 1; cat /bogus/file/DNE"
                    monitor_interval: 1
                    restart_delay: 2
        """)
        self.start_with_config(config)
        service_name = 'MASTER.service_restart'
        service_url = self.client.get_url(service_name)
        self.sandbox.tronctl('start', service_name)

        waiter = sandbox.build_waiter_func(self.client.service, service_url)
        waiter(service.ServiceState.FAILED)
        service_content = self.client.service(service_url)
        expected = 'cat: /bogus/file/DNE: No such file or directory'
        assert_in(service_content['instances'][0]['failures'][0], expected)
        waiter(service.ServiceState.STARTING)
开发者ID:Codeacious,项目名称:Tron,代码行数:21,代码来源:trond_test.py


示例18: test_render_template

 def test_render_template(self):
     config_content = "asdf asdf"
     container = self.manager.load.return_value = mock.create_autospec(
         config_parse.ConfigContainer)
     container.get_node_names.return_value = ['one', 'two', 'three']
     container.get_master.return_value.command_context = {'zing': 'stars'}
     content = self.controller.render_template(config_content)
     assert_in('# one\n# three\n# two\n', content)
     assert_in('# %-30s: %s' % ('zing', 'stars'), content)
     assert_in(config_content, content)
开发者ID:Codeacious,项目名称:Tron,代码行数:10,代码来源:controller_test.py


示例19: test_run_testify_test_file_class_and_method

 def test_run_testify_test_file_class_and_method(self):
     output = test_call([
             'python', 'testing_suite/example_test.py', '-v',
             'ExampleTestCase.test_one'])
     assert_in('PASSED.  1 test', output)
开发者ID:pyarnold,项目名称:Testify,代码行数:5,代码来源:test_program_test.py


示例20: test_run_testify_test_file_class

 def test_run_testify_test_file_class(self):
     output = test_call([
             'python', 'testing_suite/example_test.py', '-v',
             'ExampleTestCase'])
     assert_in('PASSED.  2 tests', output)
开发者ID:pyarnold,项目名称:Testify,代码行数:5,代码来源:test_program_test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python assertions.assert_raises函数代码示例发布时间:2022-05-27
下一篇:
Python assertions.assert_equal函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap