Beispiel #1
0
def test_warn():
    with pytest.warns(DeprecationWarning) as ctx:
        helpers.deprecated_noop('Text')

    w = ctx.list[0]

    assert str(w.message) == 'Text'
    # Assert the warning points at us and not at _CoroGuard.
    assert w.filename == __file__
Beispiel #2
0
def test_warn():
    with pytest.warns(DeprecationWarning) as ctx:
        helpers.deprecated_noop('Text')

    w = ctx.list[0]

    assert str(w.message) == 'Text'
    # Assert the warning points at us and not at _CoroGuard.
    assert w.filename == __file__
Beispiel #3
0
    def close(self):
        """
        对ClientSession类的close方法进行重写
        """
        if not self.closed:
            if self._connector_owner:
                self._connector.close()
            connector.append(self._connector)

        return deprecated_noop('ClientSession.close() is a coroutine')
Beispiel #4
0
def test_no_warn_on_await():
    with pytest.warns(None) as ctx:
        yield from helpers.deprecated_noop('Text')
    assert not ctx.list
Beispiel #5
0
def test_coro_guard_close():
    guard = helpers.deprecated_noop('Text')
    guard.close()
    assert not guard.gi_running
Beispiel #6
0
def test_warn():
    with pytest.warns(DeprecationWarning) as ctx:
        helpers.deprecated_noop('Text')
    assert str(ctx.list[0].message) == 'Text'
Beispiel #7
0
def test_no_warn_on_await():
    with pytest.warns(None) as ctx:
        yield from helpers.deprecated_noop('Text')
    assert not ctx.list
Beispiel #8
0
def test_warn():
    with pytest.warns(DeprecationWarning) as ctx:
        helpers.deprecated_noop('Text')
    assert str(ctx.list[0].message) == 'Text'