예제 #1
0
def test_strip_quotes_with_quotes():
    """Test that strings with quotes in them are handled during unquoting."""

    s1 = 'Darth Vader said, "Luke, I am your father."'
    assert s1 == strip_matching_quotes(s1)

    s2 = '"Darth Vader said, "Luke, I am your father.""'
    assert s2[1:-1] == strip_matching_quotes(s2)
예제 #2
0
def test_strip_quotes_with_none():
    """Test that None is handled during unquoting."""

    assert None is strip_matching_quotes(None)
예제 #3
0
def test_strip_quotes_with_unmatching_quotes():
    """Test that a string with unmatching quotes is not unquoted."""

    s = "May the force be with you."
    assert '"' + s == strip_matching_quotes('"{}'.format(s))
    assert s + "'" == strip_matching_quotes("{}'".format(s))
예제 #4
0
def test_strip_quotes_with_empty_string():
    """Test that an empty string is handled during unquoting."""

    assert '' == strip_matching_quotes('')
예제 #5
0
def test_strip_quotes_with_matching_quotes():
    """Test that a string with matching quotes is unquoted."""

    s = "May the force be with you."
    assert s == strip_matching_quotes('"{}"'.format(s))
    assert s == strip_matching_quotes("'{}'".format(s))