Ejemplo n.º 1
0
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")
Ejemplo n.º 2
0
    def test_save_text_slash_exception(self):
        sample_str = "not a list"
        file_named = r"te/st_1_error.txt"

        with pytest.raises(TypeError):
            result = save_text(file_named, sample_str)
            assert result is None
Ejemplo n.º 3
0
    def test_save_text_exception(self):
        sample_list = ["not a str"]
        file_named = "test_1_error.txt"

        with pytest.raises(TypeError):
            result = save_text(file_named, sample_list)
            assert result is None
Ejemplo n.º 4
0
    def test_save_text(self):
        sample_html = """
                        <!DOCTYPE html>
                        <html>
                        <body>

                        <h1>This is a Test File</h1>

                        <p>Created by Pytest.</p>

                        </body>
                        </html>
                        """

        file_named = "test_1.html"

        result = save_text(file_named, sample_html)
        assert result == "complete"
Ejemplo n.º 5
0
    def test_save_text_slash_exception(self):
        sample_str = "not a list"
        file_named = r"te/st_1_error.txt"

        with pytest.raises(Exception):
            assert save_text(file_named, sample_str)
Ejemplo n.º 6
0
    def test_save_text_exception(self):
        sample_list = ["not a str"]
        file_named = "test_1_error.txt"

        with pytest.raises(Exception):
            assert save_text(file_named, sample_list)