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

Python subprocess.assert_command函数代码示例

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

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



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

示例1: it_fails_with_multiple_services

def it_fails_with_multiple_services():
    assert_command(
        ('pgctl-2015', 'debug', 'abc', 'def'),
        '',
        '[pgctl] ERROR: Must debug exactly one service, not: abc, def\n',
        1,
    )
开发者ID:kleopatra999,项目名称:pgctl,代码行数:7,代码来源:debug.py


示例2: it_can_be_run_via_python_m

    def it_can_be_run_via_python_m(self, tmpdir):
        from sys import executable
        expected_output = '''\
{
    "app": "app",
    "app/a": "app/a",
    "app/b": "app/b",
    "apps": [
        "1",
        "2",
        "3"
    ],
    "environ": "environ",
    "environs": [
        "1",
        "2",
        "3"
    ],
    "etc": "etc",
    "home": "home"
}
'''
        with setup(tmpdir):
            assert_command(
                (executable, '-m', 'pgctl.config', 'my'),
                expected_output,
                '',
                0,
                norm=norm_trailing_whitespace_json,
            )
开发者ID:Yelp,项目名称:pgctl,代码行数:30,代码来源:config.py


示例3: it_restarts_on_unready

def it_restarts_on_unready():

    def it_is_ready():
        assert_svstat('playground/slow-startup', state='ready')

    def it_becomes_unready():
        from testfixtures import Comparison as C
        from pgctl.daemontools import svstat
        assert svstat('playground/slow-startup') != C(SvStat, {'state': 'ready'}, strict=False)

    it_can_succeed()
    os.remove('playground/slow-startup/readyfile')
    wait_for(it_becomes_unready)
    wait_for(it_is_ready)

    assert_command(
        ('pgctl-2015', 'log'),
        '''\
==> playground/slow-startup/log <==
{TIMESTAMP} pgctl-poll-ready: service's ready check succeeded
{TIMESTAMP} pgctl-poll-ready: service's ready check failed -- we are restarting it for you
{TIMESTAMP} [pgctl] Stopping: slow-startup
{TIMESTAMP} [pgctl] Stopped: slow-startup
{TIMESTAMP} [pgctl] Starting: slow-startup
{TIMESTAMP} pgctl-poll-ready: service's ready check succeeded
{TIMESTAMP} [pgctl] Started: slow-startup
''',
        '',
        0,
        norm=norm.pgctl,
    )
开发者ID:kentwills,项目名称:pgctl,代码行数:31,代码来源:slow_startup.py


示例4: it_times_out

def it_times_out():
    assert_command(
        ('pgctl-2015', 'start'),
        '''\
''',
        '''\
[pgctl] Starting: slow-startup
[pgctl] ERROR: service 'slow-startup' failed to start after {TIME} seconds, its status is up (pid {PID}) {TIME} seconds
==> playground/slow-startup/log <==
[pgctl] Stopping: slow-startup
[pgctl] Stopped: slow-startup
[pgctl] ERROR: Some services failed to start: slow-startup
''',
        1,
        norm=norm.pgctl,
    )
    assert_svstat('playground/slow-startup', state=SvStat.UNSUPERVISED)

    assert_command(
        ('pgctl-2015', 'log'),
        '''\
==> playground/slow-startup/log <==
{TIMESTAMP} pgctl-poll-ready: service is stopping -- quitting the poll
''',
        '',
        0,
        norm=norm.pgctl,
    )
开发者ID:kentwills,项目名称:pgctl,代码行数:28,代码来源:slow_startup.py


示例5: it_shows_error_on_stop_for_sweet

    def it_shows_error_on_stop_for_sweet(self):
        check_call(('pgctl', 'start', 'sweet'))
        assert_command(
            ('pgctl', 'restart', 'sweet'),
            '',
            '''\
[pgctl] Stopping: sweet
[pgctl] ERROR: service 'sweet' failed to stop after {TIME} seconds, these runaway processes did not stop:
{PS-HEADER}
{PS-STATS} sleep infinity

There are two ways you can fix this:
  * temporarily: pgctl stop sweet --force
  * permanently: http://pgctl.readthedocs.org/en/latest/user/quickstart.html#writing-playground-services

==> playground/sweet/logs/current <==
{TIMESTAMP} sweet
{TIMESTAMP} sweet_error
[pgctl]
[pgctl] There might be useful information further up in the log; you can view it by running:
[pgctl]     less +G playground/sweet/logs/current
[pgctl] ERROR: Some services failed to stop: sweet
''',
            1,
            norm=norm.pgctl,
        )
开发者ID:Yelp,项目名称:pgctl,代码行数:26,代码来源:dirty_tests.py


示例6: it_starts_up_fine

    def it_starts_up_fine(self):
        assert_command(
            ('pgctl', 'start'),
            '',
            '''\
[pgctl] Starting: slow-startup, sweet
[pgctl] Started: sweet
[pgctl] Started: slow-startup
''',
            0,
        )
        assert_command(
            ('pgctl', 'log'),
            '''\
==> playground/slow-startup/logs/current <==
{TIMESTAMP} pgctl-poll-ready: service's ready check succeeded

==> playground/sweet/logs/current <==
{TIMESTAMP} sweet
{TIMESTAMP} sweet_error
''',
            '',
            0,
            norm=norm.pgctl,
        )
开发者ID:Yelp,项目名称:pgctl,代码行数:25,代码来源:dirty_tests.py


示例7: it_fails_twice_but_doesnt_restart

def it_fails_twice_but_doesnt_restart():

    def it_is_ready():
        assert_svstat('playground/unreliable', state='ready')

    assert_command(
        ('pgctl-2015', 'start'),
        '',
        '[pgctl] Starting: unreliable\n[pgctl] Started: unreliable\n',
        0
    )
    wait_for(it_is_ready)

    assert_command(
        ('pgctl-2015', 'log'),
        '''\
==> playground/unreliable/log <==
{TIMESTAMP} pgctl-poll-ready: service's ready check succeeded
{TIMESTAMP} pgctl-poll-ready: failed (restarting in 2.00 seconds)
{TIMESTAMP} pgctl-poll-ready: failed (restarting in 1.99 seconds)
''',
        '',
        0,
        norm=norm.timestamp,
    )
开发者ID:kleopatra999,项目名称:pgctl,代码行数:25,代码来源:unreliable.py


示例8: it_can_detect_cycles

 def it_can_detect_cycles(self, in_example_dir):
     assert_command(
         ("pgctl-2015", "start", "b"),
         "",
         "[pgctl] ERROR: Circular aliases! Visited twice during alias expansion: 'b'\n",
         1,
     )
开发者ID:kentwills,项目名称:pgctl,代码行数:7,代码来源:examples.py


示例9: it_can_accept_different_environment_variables

    def it_can_accept_different_environment_variables(self, in_example_dir):
        check_call(('sh', '-c', 'MYVAR=ohhi pgctl start'))

        assert_command(
            ('pgctl', 'log'),
            '''\
==> playground/environment/logs/current <==
{TIMESTAMP} ohhi
''',
            '',
            0,
            norm=norm.pgctl,
        )

        check_call(('sh', '-c', 'MYVAR=bye pgctl restart'))

        assert_command(
            ('pgctl', 'log'),
            '''\
==> playground/environment/logs/current <==
{TIMESTAMP} ohhi
{TIMESTAMP} bye
''',
            '',
            0,
            norm=norm.pgctl,
        )
开发者ID:Yelp,项目名称:pgctl,代码行数:27,代码来源:examples.py


示例10: it_can_detect_cycles

 def it_can_detect_cycles(self, in_example_dir):
     assert_command(
         ('pgctl', 'start', 'b'),
         '',
         "[pgctl] ERROR: Circular aliases! Visited twice during alias expansion: 'b'\n",
         1,
     )
开发者ID:Yelp,项目名称:pgctl,代码行数:7,代码来源:examples.py


示例11: it_shows_error_on_stop_for_sweet

    def it_shows_error_on_stop_for_sweet(self):
        assert_command(
            ('pgctl-2015', 'start', 'sweet'),
            '',
            '''\
[pgctl] Starting: sweet
[pgctl] Started: sweet
''',
            0,
        )
        assert_command(
            ('pgctl-2015', 'restart', 'sweet'),
            '',
            '''\
[pgctl] Stopping: sweet
[pgctl] ERROR: service 'sweet' failed to stop after {TIME} seconds, these runaway processes did not stop:
{PS-HEADER}
{PS-STATS} sleep infinity

There are two ways you can fix this:
  * temporarily: lsof -t playground/sweet | xargs kill -9
  * permanently: http://pgctl.readthedocs.org/en/latest/user/quickstart.html#writing-playground-services

==> playground/sweet/log <==
{TIMESTAMP} sweet
{TIMESTAMP} sweet_error
[pgctl] ERROR: Some services failed to stop: sweet
''',
            1,
            norm=norm.pgctl,
        )
开发者ID:kentwills,项目名称:pgctl,代码行数:31,代码来源:dirty_tests.py


示例12: it_can_still_show_config

    def it_can_still_show_config(self, tmpdir):
        expected_output = '''\
{
    "aliases": {
        "default": [
            "(all services)"
        ]
    },
    "command": "config",
    "force": false,
    "json": false,
    "pgdir": "playground",
    "pghome": "~/.run/pgctl",
    "poll": ".01",
    "services": [
        "default"
    ],
    "timeout": "2.0",
    "verbose": false
}
'''

        with tmpdir.as_cwd():
            assert_command(
                ('pgctl', 'config'),
                expected_output,
                '',
                0,
                norm=norm_trailing_whitespace_json,
            )
开发者ID:Yelp,项目名称:pgctl,代码行数:30,代码来源:examples.py


示例13: it_shows_stdout_and_stderr

    def it_shows_stdout_and_stderr(self, in_example_dir):
        check_call(('pgctl', 'start', 'sweet'))

        assert_command(
            ('pgctl', 'log'),
            '''\
==> playground/ohhi/logs/current <==

==> playground/sweet/logs/current <==
{TIMESTAMP} sweet
{TIMESTAMP} sweet_error
''',
            '',
            0,
            norm=norm.pgctl,
        )

        check_call(('pgctl', 'restart', 'sweet'))

        assert_command(
            ('pgctl', 'log'),
            '''\
==> playground/ohhi/logs/current <==

==> playground/sweet/logs/current <==
{TIMESTAMP} sweet
{TIMESTAMP} sweet_error
{TIMESTAMP} sweet
{TIMESTAMP} sweet_error
''',
            '',
            0,
            norm=norm.pgctl,
        )
开发者ID:Yelp,项目名称:pgctl,代码行数:34,代码来源:examples.py


示例14: it_works

    def it_works(self, in_example_dir):
        assert_command(
            ('pgctl', 'start', 'A'),
            '',
            '''\
[pgctl] Starting: A
[pgctl] Started: A
''',
            0,
        )
        wait_for(lambda: assert_command(
            ('pgctl', 'log', 'A'),
            '''\
==> playground/A/logs/current <==
{TIMESTAMP} [pgctl] Starting: B
{TIMESTAMP} [pgctl] DEBUG: parentlock: '%s/playground/A'
{TIMESTAMP} [pgctl] DEBUG: LOCK: ${LOCK}
{TIMESTAMP} [pgctl] DEBUG: loop: check_time $TIME
{TIMESTAMP} [pgctl] Started: B
{TIMESTAMP} this is stdout
{TIMESTAMP} this is stderr
''' % in_example_dir,
            '',
            0,
            norm=norm.pgctl,
        ))
        assert_command(
            ('pgctl', 'stop', 'A'),
            '',
            '''\
[pgctl] Stopping: A
[pgctl] Stopped: A
''',
            0,
        )
开发者ID:Yelp,项目名称:pgctl,代码行数:35,代码来源:examples.py


示例15: it_can_still_show_help

    def it_can_still_show_help(self, tmpdir):
        with tmpdir.as_cwd():
            assert_command(
                ('pgctl', '--help'),
                '''\
usage: pgctl [-h] [--version] [--verbose] [--pgdir PGDIR] [--pghome PGHOME]
             [--json] [--force] [--all]
             {start,stop,status,restart,reload,log,debug,config}
             [services [services ...]]

positional arguments:
  {start,stop,status,restart,reload,log,debug,config}
                        specify what action to take
  services              specify which services to act upon

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  --verbose             show additional service action information
  --pgdir PGDIR         name the playground directory
  --pghome PGHOME       directory to keep user-level playground state
  --json                output in JSON (only supported by some commands)
  --force               forcefully terminate runaway processes that prevent
                        services from starting/stopping
  --all, -a             act upon all services
''',
                '',
                0,
            )
开发者ID:Yelp,项目名称:pgctl,代码行数:29,代码来源:examples.py


示例16: assert_does_not_find

def assert_does_not_find(path):
    assert_command(
        ('pgctl-fuser', path),
        '',
        '',
        0,
    )
开发者ID:kentwills,项目名称:pgctl,代码行数:7,代码来源:fuser.py


示例17: it_runs_before_starting_a_service

    def it_runs_before_starting_a_service(self):
        assert_command(
            ('pgctl', 'start'),
            'hello, i am a pre-start script in stdout\n',
            '''\
hello, i am a pre-start script in stderr
--> $PWD basename: pre-start-hook
--> cwd basename: pre-start-hook
[pgctl] Starting: sweet
[pgctl] Started: sweet
''',
            0,
            norm=norm.pgctl,
        )

        # starting when already up doesn't trigger pre-start to run again
        assert_command(
            ('pgctl', 'start'),
            '',
            '''\
[pgctl] Already started: sweet
''',
            0,
            norm=norm.pgctl,
        )
开发者ID:Yelp,项目名称:pgctl,代码行数:25,代码来源:examples.py


示例18: it_can_accept_different_environment_variables

    def it_can_accept_different_environment_variables(self, in_example_dir):
        check_call(("sh", "-c", "MYVAR=ohhi pgctl-2015 start"))

        assert_command(
            ("pgctl-2015", "log"),
            """\
==> playground/environment/log <==
{TIMESTAMP} ohhi
""",
            "",
            0,
            norm=norm.pgctl,
        )

        check_call(("sh", "-c", "MYVAR=bye pgctl-2015 restart"))

        assert_command(
            ("pgctl-2015", "log"),
            """\
==> playground/environment/log <==
{TIMESTAMP} ohhi
{TIMESTAMP} bye
""",
            "",
            0,
            norm=norm.pgctl,
        )
开发者ID:kentwills,项目名称:pgctl,代码行数:27,代码来源:examples.py


示例19: it_shows_error_on_stop_for_slow_start

    def it_shows_error_on_stop_for_slow_start(self):
        assert_command(
            ('pgctl-2015', 'start', 'slow-startup'),
            '',
            '''\
[pgctl] Starting: slow-startup
[pgctl] Started: slow-startup
''',
            0,
        )
        assert_command(
            ('pgctl-2015', 'restart', 'slow-startup'),
            '',
            '''\
[pgctl] Stopping: slow-startup
[pgctl] ERROR: service 'slow-startup' failed to stop after {TIME} seconds, these runaway processes did not stop:
{PS-HEADER}
{PS-STATS} sleep 987654

There are two ways you can fix this:
  * temporarily: lsof -t playground/slow-startup | xargs kill -9
  * permanently: http://pgctl.readthedocs.org/en/latest/user/quickstart.html#writing-playground-services

==> playground/slow-startup/log <==
{TIMESTAMP} pgctl-poll-ready: service's ready check succeeded
{TIMESTAMP} pgctl-poll-ready: service is stopping -- quitting the poll
[pgctl] ERROR: Some services failed to stop: slow-startup
''',
            1,
            norm=norm.pgctl,
        )
开发者ID:kentwills,项目名称:pgctl,代码行数:31,代码来源:dirty_tests.py


示例20: it_shows_stdout_and_stderr

    def it_shows_stdout_and_stderr(self, in_example_dir):
        check_call(("pgctl-2015", "start", "sweet"))

        assert_command(
            ("pgctl-2015", "log"),
            """\
==> playground/ohhi/log <==

==> playground/sweet/log <==
{TIMESTAMP} sweet
{TIMESTAMP} sweet_error
""",
            "",
            0,
            norm=norm.pgctl,
        )

        check_call(("pgctl-2015", "restart", "sweet"))

        assert_command(
            ("pgctl-2015", "log"),
            """\
==> playground/ohhi/log <==

==> playground/sweet/log <==
{TIMESTAMP} sweet
{TIMESTAMP} sweet_error
{TIMESTAMP} sweet
{TIMESTAMP} sweet_error
""",
            "",
            0,
            norm=norm.pgctl,
        )
开发者ID:kentwills,项目名称:pgctl,代码行数:34,代码来源:examples.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python testifycompat.assert_equal函数代码示例发布时间:2022-05-27
下一篇:
Python regression.run函数代码示例发布时间: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