File: test_imports.py

package info (click to toggle)
python-txaio 23.1.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 456 kB
  • sloc: python: 2,521; makefile: 221; sh: 44
file content (37 lines) | stat: -rw-r--r-- 768 bytes parent folder | download | duplicates (5)
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
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