Exemple #1
0
def test_quiet_command_line():
    """Check that setting --quiet on the command line overrides project file"""

    data, _, _ = ford.parse_arguments({"quiet": True}, "quiet: false")
    assert data["quiet"] is True
    data, _, _ = ford.parse_arguments({"quiet": False}, "quiet: true")
    assert data["quiet"] is False
Exemple #2
0
def test_quiet_false():
    """This checks that bool options like 'quiet' are parsed correctly in input md file"""

    data, _, _ = ford.parse_arguments({}, "quiet: false")
    assert data["quiet"] is False
    data, _, _ = ford.parse_arguments({}, "quiet: TRUE")
    assert data["quiet"] is True
Exemple #3
0
def test_bad_preprocessor():
    class FakeFile:
        name = "test file"

    with pytest.raises(SystemExit):
        ford.parse_arguments({"project_file": FakeFile()},
                             "preprocessor: false")
Exemple #4
0
def test_repeated_docmark():
    """Check that setting --quiet on the command line overrides project file"""

    settings = """\
    docmark: !
    predocmark: !
    """

    with pytest.raises(ValueError):
        ford.parse_arguments({}, dedent(settings))

    settings = """\
    docmark: !<
    predocmark_alt: !<
    """

    with pytest.raises(ValueError):
        ford.parse_arguments({}, dedent(settings))

    settings = """\
    docmark_alt: !!
    predocmark_alt: !!
    """

    with pytest.raises(ValueError):
        ford.parse_arguments({}, dedent(settings))
Exemple #5
0
def test_path_normalisation():
    """Check that paths get normalised correctly"""

    settings = """\
    page_dir: my_pages
    src_dir: src1
             src2
    """
    data, _, _ = ford.parse_arguments({}, dedent(settings), "/prefix/path")
    assert str(data["page_dir"]) == "/prefix/path/my_pages"
    assert [str(p) for p in data["src_dir"]] == [
        "/prefix/path/src1",
        "/prefix/path/src2",
    ]
Exemple #6
0
def test_source_not_subdir_output():
    """Check if the src_dir is correctly detected as being a subdirectory of output_dir"""

    # This should be fine
    data, _, _ = ford.parse_arguments(
        {
            "src_dir": ["/1/2/3", "4/5"],
            "output_dir": "/3/4"
        }, "", "/prefix")

    # This shouldn't be
    with pytest.raises(ValueError):
        data, _, _ = ford.parse_arguments(
            {
                "src_dir": ["4/5", "/1/2/3"],
                "output_dir": "/1/2"
            }, "", "/prefix")
    # src_dir == output_dir
    with pytest.raises(ValueError):
        data, _, _ = ford.parse_arguments(
            {
                "src_dir": ["/1/2/"],
                "output_dir": "/1/2"
            }, "", "/prefix")
Exemple #7
0
def test_list_input():
    """Check that setting a non-list option is turned into a single string"""

    settings = """\
    include: line1
             line2
    summary: This
             is
             one
             string
    """
    data, _, _ = ford.parse_arguments({}, dedent(settings))

    assert len(data["include"]) == 2
    assert data["summary"] == "This\nis\none\nstring"
Exemple #8
0
def example_project(tmp_path_factory):
    this_dir = pathlib.Path(__file__).parent
    tmp_path = tmp_path_factory.getbasetemp() / "example"
    shutil.copytree(this_dir / "../example", tmp_path)

    with pytest.MonkeyPatch.context() as m:
        os.chdir(tmp_path)
        m.setattr(sys, "argv", ["ford", "example-project-file.md"])
        ford.run()

    with open(tmp_path / "example-project-file.md", "r") as f:
        project_file = f.read()
    settings, _, _ = ford.parse_arguments({}, project_file, tmp_path)

    doc_path = tmp_path / "doc"

    return doc_path, settings
Exemple #9
0
def test_gfortran_preprocessor():
    data, _, _ = ford.parse_arguments({}, "preprocessor: gfortran -E")

    assert data["preprocess"] is True
Exemple #10
0
def test_maybe_ok_preprocessor():
    data, _, _ = ford.parse_arguments({}, "preprocessor: true")

    if data["preprocess"] is True:
        assert isinstance(data["preprocessor"], list)
        assert len(data["preprocessor"]) > 0
Exemple #11
0
def test_no_preprocessor():
    data, _, _ = ford.parse_arguments({}, "preprocess: False")

    assert data["fpp_extensions"] == []