예제 #1
0
def test_full_example():
    name = 'Booboo'
    interests = {'being': 'cool'}
    assert (
        f('My name is {name!s:>8} and I like {interests!r} years old') ==
        "My name is   Booboo and I like {'being': 'cool'} years old"
    )
예제 #2
0
def test_conversion_r():
    name = 'Booboo'
    assert f('{name!r}') == "'" + name + "'"
예제 #3
0
def test_conversion_invalid():
    name = 'Booboo'
    with pytest.raises(ValueError):
        f('{name!z}')
예제 #4
0
def test_format_spec():
    name = 'Boo'
    assert f('{name:>5}') == '  Boo'
예제 #5
0
def test_conversion_s():
    number = 123
    assert f('{number!s}') == '123'
예제 #6
0
def test_expression_variables():
    name = 'Booboo'
    assert f('{name}') == name
예제 #7
0
def test_expression_variables_complex():
    name = 'Booboo'
    assert f('{name[0] + "ah"}') == 'Bah'
예제 #8
0
def test_expression_variables():
    name = 'Booboo'
    assert f('{name}') == name
예제 #9
0
def test_literal_string():
    assert f('hello') == 'hello'
예제 #10
0
def test_full_example():
    name = 'Booboo'
    interests = {'being': 'cool'}
    assert (f('My name is {name!s:>8} and I like {interests!r} years old') ==
            "My name is   Booboo and I like {'being': 'cool'} years old")
예제 #11
0
def test_literal_string():
    assert f('hello') == 'hello'
예제 #12
0
def test_conversion_invalid():
    name = 'Booboo'
    with pytest.raises(ValueError):
        f('{name!z}')
예제 #13
0
def test_conversion_r():
    name = 'Booboo'
    assert f('{name!r}') == "'" + name + "'"
예제 #14
0
def test_conversion_s():
    number = 123
    assert f('{number!s}') == '123'
예제 #15
0
def test_format_spec():
    name = 'Boo'
    assert f('{name:>5}') == '  Boo'
예제 #16
0
def test_expression_variables_complex():
    name = 'Booboo'
    assert f('{name[0] + "ah"}') == 'Bah'