Source

snippy / tests / test_basic.py

from snippy import snippy

long_test = "0123456789"*10
short_test = "0123456789"

def test_default_length():
    result = snippy.snip(long_test)
    assert len(result) == 80, \
           "Default length is %d, not 80." % (len(result),)

def test_default_postfix():
    result = snippy.snip(long_test)
    assert result.endswith('...'), \
           "Default postfix is not '...'"

def test_specified_length():
    result = snippy.snip(long_test, length=20)
    assert len(result) == 20, \
           "Specified length of 20 but got %d." % (len(result),)

def test_specified_postfix():
    result = snippy.snip(long_test, postfix='-post')
    assert result.endswith('-post'), \
           "Specified postfix but did not get it."

def test_specified_length_postfix():
    result = snippy.snip(long_test, length=20, postfix='-post')
    assert len(result) == 20 and result.endswith('-post'), \
           "Specified length and postfix but didn't get them."