コード例 #1
0
def test_path_with_correct_exten():
    rpc = ReactivePathChecker("ajxoj/io.txt", ".pdf", "awesomeArg")
    correct_path = rpc.path_with_correct_exten()
    assert correct_path in (Path("ajxoj/io.pdf"), Path("ajxoj\\io.pdf"))
コード例 #2
0
def test_check_path_is_file():
    rpc = ReactivePathChecker("some_dir", "", "awesomeArg")
    except_msg = "awesomeArg must be the path to a file."
    with pytest.raises(ValueError, match=except_msg):
        rpc.check_path_is_file()
コード例 #3
0
def test_name_with_correct_exten():
    rpc = ReactivePathChecker("ajxoj/io.txt", ".pdf", "awesomeArg")
    assert rpc.name_with_correct_exten() == "io.pdf"
コード例 #4
0
def test_check_path_exists():
    rpc = ReactivePathChecker("ajxoj/io.txt", ".pdf", "awesomeArg")
    with pytest.raises(FileNotFoundError):
        rpc.check_path_exists()
コード例 #5
0
def test_check_path_is_dir():
    rpc = ReactivePathChecker("some_dir/un_fichier_pdf.pdf", ".pdf",
                              "awesomeArg")
    except_msg = "awesomeArg must be the path to a directory."
    with pytest.raises(ValueError, match=except_msg):
        rpc.check_path_is_dir()
コード例 #6
0
def test_check_extension_correct():
    rpc = ReactivePathChecker("ajxoj/io.txt", ".pdf", "awesomeArg")
    except_msg =\
     "awesomeArg must be the path to a file with the extension '.pdf'."
    with pytest.raises(ValueError, match=except_msg):
        rpc.check_extension_correct()
コード例 #7
0
def test_init():
    rpc = ReactivePathChecker("ajxoj/io.txt", ".pdf", "awesomeArg")
    assert rpc.path == Path("ajxoj/io.txt")
    assert rpc.extension == ".pdf"
    assert rpc.arg_name == "awesomeArg"
コード例 #8
0
def test_repr():
    rpc = ReactivePathChecker("ajxoj/io.txt", ".pdf", "awesomeArg")
    assert repr(rpc) in (
        "ReactivePathChecker('ajxoj/io.txt', '.pdf', 'awesomeArg')",
        "ReactivePathChecker('ajxoj\\io.txt', '.pdf', 'awesomeArg')")
コード例 #9
0
def test_pc_eq_rpc():
    pc = PathChecker("ajxoj/io.txt", ".pdf")
    rpc = ReactivePathChecker("ajxoj/io.txt", ".pdf", "awesomeArg")
    assert pc != rpc
コード例 #10
0
def test_eq_false():
    rpc1 = ReactivePathChecker("ajxoj/io.txt", ".pdf", "awesomeArg")
    rpc2 = ReactivePathChecker("ajxoj/io.txt", ".pdf", "formidableArg")
    assert rpc1 != rpc2
コード例 #11
0
def test_eq_true():
    rpc1 = ReactivePathChecker("ajxoj/io.txt", ".pdf", "awesomeArg")
    rpc2 = ReactivePathChecker("ajxoj/io.txt", ".pdf", "awesomeArg")
    assert rpc1 == rpc2
コード例 #12
0
def test_make_reactive_path_checker():
    warner = MissingPathArgWarner("awesomeArg", ".pdf")
    rpc = warner.make_reactive_path_checker("ajxoj/io.txt")
    assert rpc == ReactivePathChecker("ajxoj/io.txt", ".pdf", "awesomeArg")