Ejemplo n.º 1
0
from termcolor import colored

from hell import T
from conftest import capture_out

t = capture_out(T)


def test_arg():
    assert t('') == colored("<class 'str'>\n")
    assert t(1) == colored("<class 'int'>\n")


def test_c():
    assert t(object, c='green') == colored("<class 'type'>\n", 'green')
    assert t(type, c='b') == colored("<class 'type'>\n", 'blue')


def test_b():
    assert t({}, b='green') == colored("<class 'dict'>\n", on_color='on_green')


def test_a_str():
    assert t(0.0, a='underline') == colored("<class 'float'>\n",
                                            attrs=['underline'])


def test_a_short_list():
    assert t(None, a=['u']) == colored("<class 'NoneType'>\n",
                                       attrs=['underline'])
Ejemplo n.º 2
0
from termcolor import colored

from hell import M
from conftest import capture_out

m = capture_out(M)


def test_arg_zero():
    assert m(0) == colored('int | object\n')


def test_arg_int():
    assert m(int) == colored('int | object\n')


def test_arg_bool():
    assert m(bool) == colored('bool | int | object\n')


def test_arg_type():
    assert m(type) == colored('type | object\n')


def test_sep():
    assert m(0, sep=', ') == colored('int, object\n')


def test_c():
    assert m(1, c='green') == colored('int | object\n', 'green')
Ejemplo n.º 3
0
from pprint import pformat

from termcolor import colored

from hell import PP
from conftest import capture_out

pp = capture_out(PP)

mars = {
    'name':
    'Mars',
    'mass':
    6.4171e+23,
    'radius':
    3389.5,
    'satellites': [{
        'name': 'Phobos',
        'mass': 1.0659e+16,
        'radius': 11.2667
    }, {
        'name': 'Deimos',
        'mass': 1.4762e+15,
        'radius': 6.2
    }],
}

numbers = list(range(100))


def _pformat(*args, **kwargs):
Ejemplo n.º 4
0
# -*- coding: utf-8 -*-
from hell import P
from conftest import capture_out


p = capture_out(P)


def test_args():

    assert p() == '\n'
    assert p('') == '\n'
    assert p('A') == 'A\n'
    assert p(1) == '1\n'
    assert p('A', 1) == 'A 1\n'
    assert p([0, 1, 'A']) == "[0, 1, 'A']\n"


def test_kwargs():

    assert p('', end= '.') == '.'
    assert p('A', sep= '|') == 'A\n'
    assert p('A', 1, sep= '|') == 'A|1\n'
    assert p('A', 1, end='.', sep='|') == 'A|1.'


def test_unicode():

    assert p('í') == u'\xed\n'
    assert p('1', end='€') == u'1\u20ac'
    assert p(u'\u2019') == u'\u2019\n'