示例#1
0
 def test_cut_by_lines_line_ending(self):
     assert cut_by_lines(text="test\rtest", seg_size=1,
                         overlap=0, last_prop=1) == ["test\r", "test"]
     assert cut_by_lines(text="test\rtest\ntest", seg_size=1,
                         overlap=0, last_prop=1) == ["test\r",
                                                     "test\n", "test"]
     assert cut_by_lines(text="test\r\ntest\ntest", seg_size=2, overlap=1,
                         last_prop=200) == [
         "test\r\ntest\ntest"]
示例#2
0
 def test_cut_by_lines_regular(self):
     assert cut_by_lines(text="test", seg_size=100, overlap=0,
                         last_prop=0.5) == ["test"]
     assert cut_by_lines(text="test", seg_size=1,
                         overlap=0, last_prop=1) == ["test"]
     assert cut_by_lines(text="test\ntest\ntest", seg_size=2,
                         overlap=1, last_prop=1) == ["test\ntest\n",
                                                     "test\ntest"]
     assert cut_by_lines(text="test\ntest\ntest", seg_size=1,
                         overlap=0, last_prop=200) == ["test\ntest\ntest"]
     assert cut_by_lines(text="   \n\ntest", seg_size=1, overlap=0,
                         last_prop=1) == ["   \n", "\n", "test"]
示例#3
0
 def test_cut_by_lines_line_ending(self):
     assert cut_by_lines(text="test\rtest",
                         seg_size=1,
                         overlap=0,
                         last_prop=1) == ["test\r", "test"]
     assert cut_by_lines(text="test\rtest\ntest",
                         seg_size=1,
                         overlap=0,
                         last_prop=1) == ["test\r", "test\n", "test"]
     assert cut_by_lines(text="test\r\ntest\ntest",
                         seg_size=2,
                         overlap=1,
                         last_prop=200) == ["test\r\ntest\ntest"]
示例#4
0
 def test_cut_by_lines_regular(self):
     assert cut_by_lines(text="test",
                         seg_size=100,
                         overlap=0,
                         last_prop=0.5) == ["test"]
     assert cut_by_lines(text="test", seg_size=1, overlap=0,
                         last_prop=1) == ["test"]
     assert cut_by_lines(text="test\ntest\ntest",
                         seg_size=2,
                         overlap=1,
                         last_prop=1) == ["test\ntest\n", "test\ntest"]
     assert cut_by_lines(text="test\ntest\ntest",
                         seg_size=1,
                         overlap=0,
                         last_prop=200) == ["test\ntest\ntest"]
     assert cut_by_lines(text="   \n\ntest",
                         seg_size=1,
                         overlap=0,
                         last_prop=1) == ["test"]
示例#5
0
 def test_cut_by_lines_larger_seg_size(self):
     try:
         _ = cut_by_lines(text="", seg_size=1, overlap=2, last_prop=1)
         raise AssertionError("smaller seg_size error did not raise")
     except AssertionError as error:
         assert str(error) == LARGER_SEG_SIZE_MESSAGE
示例#6
0
 def test_cut_by_lines_neg_nums(self):
     try:
         _ = cut_by_lines(text="", seg_size=1, overlap=-1, last_prop=-1)
         raise AssertionError("negative number error did not raise")
     except AssertionError as error:
         assert str(error) == NEG_OVERLAP_LAST_PROP_MESSAGE
示例#7
0
 def test_cut_by_lines_zero_seg_size(self):
     try:
         _ = cut_by_lines(text="", seg_size=0, overlap=0, last_prop=1)
         raise AssertionError("zero seg_size error did not raise")
     except AssertionError as error:
         assert str(error) == SEG_NON_POSITIVE_MESSAGE
示例#8
0
 def test_cut_by_lines_empty(self):
     assert cut_by_lines(text="", seg_size=1, overlap=0, last_prop=1) == []
     assert cut_by_lines(text="\n", seg_size=1, overlap=0,
                         last_prop=1) == []
示例#9
0
 def test_cut_by_lines_larger_seg_size(self):
     try:
         _ = cut_by_lines(text="", seg_size=1, overlap=2, last_prop=1)
         raise AssertionError("smaller seg_size error did not raise")
     except AssertionError as error:
         assert str(error) == LARGER_SEG_SIZE_MESSAGE
示例#10
0
 def test_cut_by_lines_neg_nums(self):
     try:
         _ = cut_by_lines(text="", seg_size=1, overlap=-1, last_prop=-1)
         raise AssertionError("negative number error did not raise")
     except AssertionError as error:
         assert str(error) == NEG_OVERLAP_LAST_PROP_MESSAGE
示例#11
0
 def test_cut_by_lines_zero_seg_size(self):
     try:
         _ = cut_by_lines(text="", seg_size=0, overlap=0, last_prop=1)
         raise AssertionError("zero seg_size error did not raise")
     except AssertionError as error:
         assert str(error) == SEG_NON_POSITIVE_MESSAGE
示例#12
0
 def test_cut_by_lines_empty(self):
     assert cut_by_lines(text="", seg_size=1, overlap=0,
                         last_prop=1) == [""]
     assert cut_by_lines(text="\n", seg_size=1, overlap=0,
                         last_prop=1) == ["\n"]