Ejemplo n.º 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"]
Ejemplo n.º 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"]
Ejemplo n.º 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"]
Ejemplo n.º 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"]
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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) == []
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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"]