Ejemplo n.º 1
0
def test_recursive_formatter_format_empty():
    """Format an empty string."""
    formatter = RecursiveFormatter()
    assert formatter.format('', 'a', 'b', 'c') == ''
Ejemplo n.º 2
0
def test_recursive_formatter_format_no_expression():
    """Format a string sans formatting expression."""
    formatter = RecursiveFormatter()
    assert formatter.format('arb string', 'a', 'b', 'c') == 'arb string'
Ejemplo n.º 3
0
def test_recursive_formatter_format_none():
    """Format a None."""
    formatter = RecursiveFormatter()
    assert formatter.format(None, 'a', 'b', 'c') is None
Ejemplo n.º 4
0
def test_recursive_formatter_format_args_and_kwargs():
    """Format a string with positional args and kwargs."""
    formatter = RecursiveFormatter()
    assert (formatter.format('{} and {b} arb {c} string', 'a', b='b',
                             c='c') == 'a and b arb c string')
Ejemplo n.º 5
0
def test_recursive_formatter_format_kwargs():
    """Format a string with kwargs."""
    formatter = RecursiveFormatter()
    assert (formatter.format('{b} arb {c} string', a='a', b='b',
                             c='c') == 'b arb c string')
Ejemplo n.º 6
0
def test_recursive_formatter_format_args_no_index():
    """Format a string with positional args and auto index."""
    formatter = RecursiveFormatter()
    assert (formatter.format('{} arb {} string', 'a', 'b',
                             'c') == 'a arb b string')
Ejemplo n.º 7
0
def test_recursive_formatter_format_args():
    """Format a string with positional args."""
    formatter = RecursiveFormatter()
    assert (formatter.format('{0} arb {1} string', 'a', 'b',
                             'c') == 'a arb b string')