Esempio n. 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__
Esempio n. 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__
Esempio n. 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')
Esempio n. 4
0
def test_no_warn_on_await():
    with pytest.warns(None) as ctx:
        yield from helpers.deprecated_noop('Text')
    assert not ctx.list
Esempio n. 5
0
def test_coro_guard_close():
    guard = helpers.deprecated_noop('Text')
    guard.close()
    assert not guard.gi_running
Esempio n. 6
0
def test_warn():
    with pytest.warns(DeprecationWarning) as ctx:
        helpers.deprecated_noop('Text')
    assert str(ctx.list[0].message) == 'Text'
Esempio n. 7
0
def test_no_warn_on_await():
    with pytest.warns(None) as ctx:
        yield from helpers.deprecated_noop('Text')
    assert not ctx.list
Esempio n. 8
0
def test_warn():
    with pytest.warns(DeprecationWarning) as ctx:
        helpers.deprecated_noop('Text')
    assert str(ctx.list[0].message) == 'Text'