Skip to content

Commit

Permalink
Merge pull request #533 from Fortran-FOSS-Programmers/fix-tests-for-w…
Browse files Browse the repository at this point in the history
…indows

Fix some tests for Windows
  • Loading branch information
ZedThree authored Aug 2, 2023
2 parents 3657bff + 2b68f47 commit fd4a8ed
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
2 changes: 2 additions & 0 deletions test/test_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from urllib.parse import urlparse

import ford
from ford.graphs import graphviz_installed

from bs4 import BeautifulSoup
import pytest
Expand Down Expand Up @@ -231,6 +232,7 @@ def test_types_finaliser(example_project):
assert "More documentation" in finaliser_section.ul.text


@pytest.mark.skipif(not graphviz_installed, reason="Requires graphviz")
def test_graph_submodule(example_project):
path, _ = example_project
index = read_html(path / "module/test_submodule.html")
Expand Down
21 changes: 14 additions & 7 deletions test/test_initialisation.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import ford
from textwrap import dedent
from pathlib import Path
import sys
import pytest

from conftest import gfortran_is_not_installed


class FakeFile:
name = "test file"


def test_quiet_false():
"""This checks that bool options like 'quiet' are parsed correctly in input md file"""

Expand Down Expand Up @@ -50,10 +55,10 @@ def test_path_normalisation():
src2
"""
data, _, _ = ford.parse_arguments({}, dedent(settings), "/prefix/path")
assert str(data["page_dir"]) == "/prefix/path/my_pages"
assert str(data["page_dir"]) == str(Path("/prefix/path/my_pages"))
assert [str(p) for p in data["src_dir"]] == [
"/prefix/path/src1",
"/prefix/path/src2",
str(Path("/prefix/path/src1")),
str(Path("/prefix/path/src2")),
]


Expand Down Expand Up @@ -112,15 +117,17 @@ def test_no_preprocessor():


def test_bad_preprocessor():
class FakeFile:
name = "test file"

with pytest.raises(SystemExit):
ford.parse_arguments({"project_file": FakeFile()}, "preprocessor: false")


@pytest.mark.skipif(
sys.platform.startswith("win"), reason="FIXME: Need portable do-nothing command"
)
def test_maybe_ok_preprocessor():
data, _, _ = ford.parse_arguments({}, "preprocessor: true")
data, _, _ = ford.parse_arguments(
{"project_file": FakeFile()}, "preprocessor: true"
)

if data["preprocess"] is True:
assert isinstance(data["preprocessor"], list)
Expand Down
10 changes: 6 additions & 4 deletions test/test_md_inputs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import pathlib
import os.path
import re
import sys
from typing import List
from typing import List, Optional

import ford
import ford.fortran_project
Expand All @@ -12,7 +13,7 @@
DEFAULT_SRC = "src"


def run_ford(monkeypatch, md_file: pathlib.Path, extra_args: list = None):
def run_ford(monkeypatch, md_file: pathlib.Path, extra_args: Optional[list] = None):
"""Modify command line args with argv"""
with monkeypatch.context() as m:
command = ["ford", str(md_file)]
Expand Down Expand Up @@ -109,14 +110,15 @@ def test_default_aliases(

html_dir = tmp_path / "doc"
index_text = get_main_body_text(html_dir, "index.html")
media_dir = os.path.join(".", "media")
expected_index_text = [
"Test: The project media url should be ./media",
f"Test: The project media url should be {media_dir}",
]
assert index_text == expected_index_text

module_text = get_main_body_text(html_dir, "module/test.html")
expected_module_text = [
"Test: The project media url (./media) should work here too"
f"Test: The project media url ({media_dir}) should work here too"
]
assert module_text == expected_module_text

Expand Down

0 comments on commit fd4a8ed

Please sign in to comment.