File: test_utils.py

package info (click to toggle)
python-easysnmp 0.2.6-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 540 kB
  • sloc: ansic: 3,735; python: 1,410; makefile: 161
file content (30 lines) | stat: -rw-r--r-- 726 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
from __future__ import unicode_literals

from easysnmp.compat import ub
from easysnmp.utils import strip_non_printable, tostr


def test_strip_non_printable_regular():
    assert strip_non_printable("hello there") == "hello there"


def test_strip_non_printable_contains_binary():
    assert strip_non_printable(ub(chr(20)) + "my thingo" + ub(chr(155))) == (
        "my thingo (contains binary)"
    )


def test_strip_non_printable_only_binary():
    assert strip_non_printable(ub(chr(20)) + ub(chr(155))) == ("(contains binary)")


def test_tostr_none():
    assert tostr(None) is None


def test_tostr_string():
    assert tostr("hello there") == "hello there"


def test_tostr_integer():
    assert tostr(1234) == "1234"