File: test_core_make_val.py

package info (click to toggle)
grass 7.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 135,976 kB
  • ctags: 44,148
  • sloc: ansic: 410,300; python: 166,939; cpp: 34,819; sh: 9,358; makefile: 6,618; xml: 3,551; sql: 769; lex: 519; yacc: 450; asm: 387; perl: 282; sed: 17; objc: 7
file content (31 lines) | stat: -rw-r--r-- 769 bytes parent folder | download | duplicates (2)
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
# -*- coding: utf-8 -*-

from grass.gunittest.case import TestCase
from grass.gunittest.main import test

from grass.script.core import _make_val


class TestCoreMakeVal(TestCase):
    """Tests function `_make_val` that convert value to bytes."""

    def test_bytes(self):
        self.assertEqual(b'text', _make_val(b'text'))

    def test_unicode(self):
        self.assertEqual(b'text', _make_val(u'text'))

    def test_int(self):
        self.assertEqual(b'123', _make_val(123))

    def test_float(self):
        self.assertEqual(b'1.23', _make_val(1.23))

    def test_iterable(self):
        test = b'text', u'text', 123, 1.23
        solution = b'text,text,123,1.23'
        self.assertEqual(solution, _make_val(test))


if __name__ == '__main__':
    test()