Beispiel #1
0
def run_ascii():
    char_list = []
    char_list_csv = open_csv("ascii2.csv")

    for c in char_list_csv:
        char = c["Symbol"]
        if char.isprintable() == True:
            char_list.append(char)

    err_list = []
    count = 0

    for l in tqdm(char_list, desc="left char", leave=False, ascii=True):
        for r in tqdm(char_list, desc="right char", leave=False, ascii=True):
            for s in tqdm(char_list,
                          desc="split char",
                          leave=False,
                          ascii=True):
                """# time.sleep(.001)"""
                loop_char = [l, r]
                if s not in loop_char:
                    text = f"{s}{l}found one{r}{s}{s}{l}found two{r}"
                    data = pattern_between(text, l, r, s)
                    count += 1

                    if "Error" in data:
                        err_list.append(data)

    return err_list, char_list, count
Beispiel #2
0
    def test_create_sample_files(self):
        filename = "test_sample"
        samplesize = 1000
        create_sample_files(filename, samplesize)

        file_named = "test_1.csv"
        result = open_csv(file_named)
        assert len(result) == samplesize - 1
Beispiel #3
0
 def test_open_csv_no_file(self):
     file_named = "no_file_name.csv"
     # result = open_csv(file_named)
     # assert result["error"].startswith("ERROR")
     m = mock.Mock()
     m.side_effect = Exception(open_csv(file_named))
     try:
         m()
     except Exception:
         assert True
Beispiel #4
0
    def test_pattern_between_two_char(self):
        char_list = []
        char_list_csv = open_csv("ascii2.csv")

        for c in char_list_csv:
            char = c["Symbol"]
            if char.isprintable() == True:
                char_list.append(char)

        err_list = []

        for l in char_list:
            for r in char_list:
                text = f"{l}found one{r} {l}found two{r}"
                data = pattern_between_two_char(text, l, r)

                if "Error" in data:
                    err_list.append(data)

        assert len(err_list) == 0
Beispiel #5
0
def run_ascii_two():
    char_list = []
    char_list_csv = open_csv("ascii2.csv")

    for c in char_list_csv:
        char = c["Symbol"]
        if char.isprintable() == True:
            char_list.append(char)

    err_list = []
    count = 0

    for l in tqdm(char_list, desc="left char", leave=False, ascii=True):
        for r in tqdm(char_list, desc="right char", leave=False, ascii=True):

            text = f"{l}found one{r} {l}found two{r}"
            data = pattern_between_two_char(text, l, r)

            if "Error" in data:
                err_list.append(data)

    return err_list, char_list, count
Beispiel #6
0
 def test_open_csv(self):
     file_named = "test_1.csv"
     result = open_csv(file_named)
     assert len(result) > 1
 def test_open_csv_exception_slash_linux(self):
     file_named = "//this_is_not_right_csv"
     with pytest.raises(Exception):
         assert open_csv(file_named)
 def test_open_csv_exception_not_str(self):
     file_named = ["a", "list"]
     with pytest.raises(Exception):
         assert open_csv(file_named)
 def test_open_csv_no_file(self):
     file_named = "no_file_name.csv"
     with pytest.raises(Exception):
         assert open_csv(file_named)
 def test_open_csv_exception_slash_linux(self):
     file_named = "//this_is_not_right_csv"
     with pytest.raises(FileNotFoundError):
         result = open_csv(file_named)
         assert result is None
 def test_open_csv_exception_slash_win(self):
     file_named = "\this_is_not_right_csv"
     with pytest.raises(Exception):
         result = open_csv(file_named)
         assert result is None
 def test_open_csv_no_file(self):
     file_named = "no_file_name.csv"
     with pytest.raises(Exception):
         result = open_csv(file_named)
         assert result is None