예제 #1
0
 def test_wrap_none(self):
     text = None
     try:
         misc.wrap(text, width=5)
     except TypeError as e:
         self.eq(e.args[0],
                 "Argument `text` must be one of [str, unicode].")
         raise
예제 #2
0
파일: misc_tests.py 프로젝트: Ichag/cement
    def test_wrap_str(self):
        text = "aaaaa bbbbb ccccc"
        new_text = misc.wrap(text, width=5)
        parts = new_text.split("\n")
        self.eq(len(parts), 3)
        self.eq(parts[1], "bbbbb")

        new_text = misc.wrap(text, width=5, indent="***")
        parts = new_text.split("\n")
        self.eq(parts[2], "***ccccc")
예제 #3
0
    def test_wrap_str(self):
        text = "aaaaa bbbbb ccccc"
        new_text = misc.wrap(text, width=5)
        parts = new_text.split('\n')
        self.eq(len(parts), 3)
        self.eq(parts[1], 'bbbbb')

        new_text = misc.wrap(text, width=5, indent='***')
        parts = new_text.split('\n')
        self.eq(parts[2], '***ccccc')
예제 #4
0
def test_wrap_str():
    text = "aaaaa bbbbb ccccc"
    new_text = misc.wrap(text, width=5)
    parts = new_text.split('\n')
    assert len(parts) == 3
    assert parts[1] == 'bbbbb'

    new_text = misc.wrap(text, width=5, indent='***')
    parts = new_text.split('\n')
    assert parts[2] == '***ccccc'
예제 #5
0
    def test_wrap_unicode(self):
        # str is unicode in py3
        if sys.version_info[0] >= 3:
            raise test.SkipTest

        text = unicode('aaaaa bbbbb ccccc')  # noqa: F821
        new_text = misc.wrap(text, width=5)
        parts = new_text.split('\n')
        self.eq(len(parts), 3)
        self.eq(parts[1], unicode('bbbbb'))  # noqa: F821

        new_text = misc.wrap(text, width=5, indent='***')
        parts = new_text.split('\n')
        self.eq(parts[2], unicode('***ccccc'))  # noqa: F821
예제 #6
0
    def test_wrap_unicode(self):
        # str is unicode in py3
        if sys.version_info[0] >= 3:
            raise test.SkipTest

        text = unicode('aaaaa bbbbb ccccc')
        new_text = misc.wrap(text, width=5)
        parts = new_text.split('\n')
        self.eq(len(parts), 3)
        self.eq(parts[1], unicode('bbbbb'))

        new_text = misc.wrap(text, width=5, indent='***')
        parts = new_text.split('\n')
        self.eq(parts[2], unicode('***ccccc'))
예제 #7
0
파일: misc_tests.py 프로젝트: Ichag/cement
 def test_wrap_none(self):
     text = None
     try:
         new_text = misc.wrap(text, width=5)
     except TypeError as e:
         self.eq(e.args[0], "`text` must be a string.")
         raise
예제 #8
0
 def test_wrap_none(self):
     text = None
     try:
         new_text = misc.wrap(text, width=5)
     except TypeError as e:
         self.eq(e.args[0], "`text` must be a string.")
         raise
예제 #9
0
 def test_wrap_none(self):
     text = None
     try:
         new_text = misc.wrap(text, width=5)
     except TypeError as e:
         self.eq(e.args[0], 
                 "Argument `text` must be one of [str, unicode].")
         raise
예제 #10
0
 def test_wrap_int(self):
     text = int('1' * 80)
     try:
         new_text = misc.wrap(text, width=5)
     except TypeError as e:
         self.eq(e.args[0], 
                 "Argument `text` must be one of [str, unicode].")
         raise
예제 #11
0
def test_wrap_non_str():
    with raises(TypeError):
        misc.wrap(int('1' * 80), width=5)

    with raises(TypeError):
        misc.wrap(None, width=5)