File: test_imports.py

package info (click to toggle)
python-txaio 25.6.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 528 kB
  • sloc: python: 2,464; makefile: 226; sh: 48
file content (41 lines) | stat: -rw-r--r-- 772 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import pytest


def test_use_twisted(framework_tx):
    pytest.importorskip("twisted")

    import txaio

    txaio.use_twisted()
    assert txaio.using_twisted
    assert not txaio.using_asyncio


def test_use_twisted_no_twisted(framework_uninitialized):
    # make sure we DO NOT have Twisted installed
    try:
        import twisted  # noqa

        return
    except ImportError:
        pass  # no Twisted

    import txaio

    try:
        txaio.use_twisted()
        assert "Should have gotten ImportError"
    except ImportError:
        pass

    assert not txaio.using_twisted


def test_use_asyncio(framework_aio):
    pytest.importorskip("asyncio")

    import txaio

    txaio.use_asyncio()
    assert txaio.using_asyncio
    assert not txaio.using_twisted