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


Python Server.wait_for_output方法代码示例

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


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

示例1: test_args_are_passed

# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import wait_for_output [as 别名]
    def test_args_are_passed(self, monkeypatch):
        """ Test that wait_for_output passes all
            Arguments to the underlying ProcessMonitor
        """
        serv = Server()
        serv.proc = Mock()
        monkeypatch.setattr(serv.proc, "wait_for_output", Mock())

        serv.wait_for_output("foo", timeout=123, count=456)
        serv.proc.wait_for_output.called_once_with("foo", timeout=123, count=456)
开发者ID:a740122,项目名称:gst-switch,代码行数:12,代码来源:test_server_unit.py

示例2: test_error_is_passed

# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import wait_for_output [as 别名]
    def test_error_is_passed(self, monkeypatch):
        """ Test that wait_for_output passes all
            Exceptions from the underlying ProcessMonitor
        """
        serv = Server()
        serv.proc = Mock()
        monkeypatch.setattr(serv.proc, "wait_for_output", Mock(side_effect=MatchTimeoutError))

        with pytest.raises(MatchTimeoutError):
            serv.wait_for_output("foo", timeout=123, count=456)
开发者ID:a740122,项目名称:gst-switch,代码行数:12,代码来源:test_server_unit.py

示例3: IntegrationTestbase

# 需要导入模块: from gstswitch.server import Server [as 别名]
# 或者: from gstswitch.server.Server import wait_for_output [as 别名]
class IntegrationTestbase(object):
    """Base class for integration tests."""

    # Tests are not allowed to have an __init__ method
    def setup_method(self, _):
        """Set up called automatically before every test_XXXX method."""
        self.log = logging.getLogger()
        self.log.setLevel(logging.DEBUG)
        logging.basicConfig(
            format="%(filename)s:%(lineno)d (%(funcName)s): %(message)s")

        self.serv = None
        self._sources = None
        self.controller = None

    def setup_server(self, record_file=False):
        """Set up a gst-switch server for testing."""
        assert self.serv is None

        self.log.info("setting up Server")
        self.serv = Server(path=PATH, video_format="debug",
                           record_file=record_file)

        self.log.info("running Server")
        self.serv.run()
        assert self.serv.is_alive()

        self.log.info("waiting for Server to open Controller-Port")
        self.serv.wait_for_output('tcp:host=::,port=5000')

        self.log.info("setting up TestSources")
        self._sources = TestSources(
            video_port=self.serv.video_port,
            audio_port=self.serv.audio_port)

    def setup_controller(self):
        """Create Controller object and call setup_controller."""
        self.log.info("setting up Controller")
        self.controller = Controller()

        self.log.info("connecting Controller to Server")
        self.controller.establish_connection()
        self.serv.wait_for_output('registered: ')

        assert self.controller.connection is not None

    def new_test_video(self, pattern=None):
        """Start a new Video-Testsource and wait until it's ready"""
        self.serv.wait_for_output(':::3000')
        self._sources.new_test_video(pattern=pattern)

    def setup_video_sources(self, count):
        """ Starts some Test-Video streams and waits until they are ready
        """
        self.log.info("starting 2 test-video sources")
        for _ in range(0, count):
            self.new_test_video()

        self.log.info("waiting for the test-video sources to come up")
        self.wait_for_sources(count)

    def new_test_audio(self, freq=110, wave=AudioSrc.WAVE_SINE):
        """Start a new Audio-Testsource and wait until it's ready"""
        self.serv.wait_for_output(':::4000')
        self._sources.new_test_audio(freq=freq, wave=wave)

    def setup_audio_sources(self, count):
        """ Starts some Test-Audio streams and waits until they are ready
        """
        self.log.info("starting 2 test-audio sources")
        for _ in range(0, count):
            self.new_test_audio()

        self.log.info("waiting for the test-audio sources to come up")
        self.wait_for_sources(count)

    def wait_for_sources(self, count):
        """ Blocks until the Server has reported, that the right number of
        preview-ports are is started
        """
        self.log.info("waiting for Server to start preview-port-outputs")
        self.serv.wait_for_output('tcpserversink name=sink', count=count)

    def teardown_method(self, _):
        """Tear down called automatically after every test_XXXX method."""
        self.controller = None

        # Kill all the sources
        if self._sources is not None:
            self.log.info("terminating Video-TestSource")
            self._sources.terminate_video()

            self.log.info("terminating Audio-TestSource")
            self._sources.terminate_audio()
        self._sources = None

        if self.serv is not None:
            self.log.info("terminating Server")
            self.serv.terminate(cov=True)

#.........这里部分代码省略.........
开发者ID:a740122,项目名称:gst-switch,代码行数:103,代码来源:baseclass.py


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