Beispiel #1
0
def test_recursive_formatter_format_empty():
    """Format an empty string."""
    formatter = RecursiveFormatter()
    assert formatter.format('', 'a', 'b', 'c') == ''
Beispiel #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'
Beispiel #3
0
def test_recursive_formatter_format_none():
    """Format a None."""
    formatter = RecursiveFormatter()
    assert formatter.format(None, 'a', 'b', 'c') is None
Beispiel #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')
Beispiel #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')
Beispiel #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')
Beispiel #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')