File: test_basic.py

package info (click to toggle)
pyroute2 0.8.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 3,700 kB
  • sloc: python: 50,245; makefile: 280; javascript: 183; ansic: 81; sh: 44; awk: 17
file content (21 lines) | stat: -rw-r--r-- 547 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import os
from contextlib import ExitStack

import pytest

from pyroute2 import GenericNetlinkSocket, TaskStats
from pyroute2.netlink import nlmsg


def test_bind_first():
    with ExitStack() as sockets:
        ts = sockets.enter_context(TaskStats())
        gs = sockets.enter_context(GenericNetlinkSocket())

        with pytest.raises(RuntimeError) as ets:
            ts.get_pid_stat(os.getpid())

        with pytest.raises(RuntimeError) as egs:
            gs.nlm_request(nlmsg(), gs.prid)

        assert ets.value.args == egs.value.args