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


Python subprocess.assert_command函数代码示例

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


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


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