예제 #1
0
def test_save_image_file(tmpdir):
    def do():
        lcc.save_image_file(SAMPLE_IMAGE_PATH, "some other file")

    report = run_func_in_test(do, tmpdir=tmpdir.mkdir("report"))

    assert_attachment(get_last_attachment(report),
                      osp.basename(SAMPLE_IMAGE_PATH), "some other file", True,
                      SAMPLE_IMAGE_CONTENT, make_file_reader(binary=True))
예제 #2
0
def test_save_image_content(tmpdir):
    def do():
        lcc.save_image_content(SAMPLE_IMAGE_CONTENT, "somefile.png",
                               "some file")

    report = run_func_in_test(do, tmpdir=tmpdir)

    assert_attachment(get_last_attachment(report), "somefile.png",
                      "some file", True, SAMPLE_IMAGE_CONTENT,
                      make_file_reader(binary=True))
예제 #3
0
def _test_save_attachment_content(tmpdir, file_name, file_content, binary_mode,
                                  file_reader):
    def do():
        lcc.save_attachment_content(file_content,
                                    file_name,
                                    binary_mode=binary_mode)

    report = run_func_in_test(do, tmpdir=tmpdir)

    assert_attachment(get_last_attachment(report), file_name, file_name, False,
                      file_content, file_reader)
예제 #4
0
def test_save_attachment_file(tmpdir):
    def do():
        filename = osp.join(tmpdir.strpath, "somefile.txt")
        with open(filename, "w") as fh:
            fh.write("some other content")
        lcc.save_attachment_file(filename, "some other file")

    report = run_func_in_test(do, tmpdir=tmpdir.mkdir("report"))

    assert_attachment(get_last_attachment(report), "somefile.txt",
                      "some other file", False, "some other content",
                      make_file_reader())
예제 #5
0
def test_prepare_image_attachment(tmpdir):
    def do():
        with lcc.prepare_image_attachment("foobar.png",
                                          "some description") as filename:
            with open(filename, "wb") as fh:
                fh.write(SAMPLE_IMAGE_CONTENT)

    report = run_func_in_test(do, tmpdir=tmpdir)

    assert_attachment(get_last_attachment(report), "foobar.png",
                      "some description", True, SAMPLE_IMAGE_CONTENT,
                      make_file_reader(binary=True))
예제 #6
0
def test_prepare_attachment(tmpdir):
    def do():
        with lcc.prepare_attachment("foobar.txt",
                                    "some description") as filename:
            with open(filename, "w") as fh:
                fh.write("some content")

    report = run_func_in_test(do, tmpdir=tmpdir)

    assert_attachment(get_last_attachment(report), "foobar.txt",
                      "some description", False, "some content",
                      make_file_reader())