forked from MetOffice/fab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
71 lines (57 loc) · 2.61 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# ##############################################################################
# (c) Crown copyright Met Office. All rights reserved.
# For further details please refer to the file COPYRIGHT
# which you should have received as part of this distribution
# ##############################################################################
'''This file is read by pytest and provides common fixtures.
'''
from unittest import mock
import pytest
from fab.tools import Category, CCompiler, FortranCompiler, Linker, ToolBox
# This avoids pylint warnings about Redefining names from outer scope
@pytest.fixture(name="mock_c_compiler")
def fixture_mock_c_compiler():
'''Provides a mock C-compiler.'''
mock_compiler = CCompiler("mock_c_compiler", "mock_exec", "suite",
version_regex="something")
mock_compiler.run = mock.Mock()
mock_compiler._version = (1, 2, 3)
mock_compiler._name = "mock_c_compiler"
mock_compiler._exec_name = "mock_c_compiler.exe"
mock_compiler._openmp_flag = "-fopenmp"
return mock_compiler
@pytest.fixture(name="mock_fortran_compiler")
def fixture_mock_fortran_compiler():
'''Provides a mock Fortran-compiler.'''
mock_compiler = FortranCompiler("mock_fortran_compiler", "mock_exec",
"suite", module_folder_flag="",
version_regex="something",
syntax_only_flag=None, compile_flag=None,
output_flag=None, openmp_flag=None)
mock_compiler.run = mock.Mock()
mock_compiler._name = "mock_fortran_compiler"
mock_compiler._exec_name = "mock_fortran_compiler.exe"
mock_compiler._version = (1, 2, 3)
return mock_compiler
@pytest.fixture(name="mock_linker")
def fixture_mock_linker():
'''Provides a mock linker.'''
mock_linker = Linker("mock_linker", "mock_linker.exe",
Category.FORTRAN_COMPILER)
mock_linker.run = mock.Mock()
mock_linker._version = (1, 2, 3)
mock_linker.add_lib_flags("netcdf", ["-lnetcdff", "-lnetcdf"])
return mock_linker
@pytest.fixture(name="tool_box")
def fixture_tool_box(mock_c_compiler, mock_fortran_compiler, mock_linker):
'''Provides a tool box with a mock Fortran and a mock C compiler.'''
tool_box = ToolBox()
tool_box.add_tool(mock_c_compiler)
tool_box.add_tool(mock_fortran_compiler)
tool_box.add_tool(mock_linker)
return tool_box
@pytest.fixture(name="psyclone_lfric_api")
def fixture_psyclone_lfric_api():
'''A simple fixture to provide the name of the LFRic API for
PSyclone.'''
return "dynamo0.3"