def text_process(): url = "https://devsetgo.com" r = requests.get(url) logger.info(f"fetching from {url}") data = r.text file_name = f"test_1.html" save_text(file_name, data) logger.info(f"save file {file_name}") # read file logger.info(f"fetching from file {file_name}") read_data = open_text(file_name) print(read_data) logger.info(f"read of file {file_name} complete")
def test_open_txt_exception_slash_linux(self): file_named = "//this_is_not_right_txt" with pytest.raises(Exception): assert open_text(file_named)
def test_open_txt_exception_not_str(self): file_named = ["a", "list"] with pytest.raises(Exception): assert open_text(file_named)
def test_open_txt_no_file(self): file_named = "no_file_name.html" with pytest.raises(Exception): assert open_text(file_named)
def test_open_text(self): file_named = "test_1.html" result = open_text(file_named) assert "Test" in str(result)
def test_open_txt_no_file(self): file_named = "no_file_name.html" with pytest.raises(Exception): result = open_text(file_named) assert result is None
def test_open_txt_exception_slash_win(self): file_named = "\this_is_not_right_txt" with pytest.raises(Exception): result = open_text(file_named) assert result is None