File: module_test.py

package info (click to toggle)
python-setproctitle 1.3.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 272 kB
  • sloc: ansic: 946; python: 659; makefile: 21
file content (47 lines) | stat: -rw-r--r-- 920 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
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from .conftest import run_script, skip_if_win32


@skip_if_win32
def test_no_import_side_effect():
    """
    Check that importing the module doesn't cause side effects.
    """
    rv = run_script(
        """
import os

def print_stuff():
    for fn in "cmdline status comm".split():
        if os.path.exists(f"/proc/self/{fn}"):
            with open(f"/proc/self/{fn}") as f:
                print(f.readline().rstrip())

print_stuff()
print("---")
import setproctitle
print_stuff()
"""
    )
    before, after = rv.split("---\n")
    assert before == after


def test_version():
    """Test that the module has a version"""
    rv = run_script(
        """
import setproctitle
print(setproctitle.__version__)
"""
    )
    assert rv


def test_c_extension_built():
    """Test that the C extension was built"""
    rv = run_script(
        """
from setproctitle import _setproctitle
"""
    )
    assert rv == ""