Coverage for tests/test_complex_function_has_dp.py: 100%
34 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-23 18:07 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-23 18:07 +0000
1# pylint: disable=W0621,C0116,C0114
2import pytest
4from castep_linter import tests
5from castep_linter.fortran.parser import get_fortran_parser
6from castep_linter.scan_files import run_tests_on_code
9@pytest.fixture
10def test_list():
11 return {"call_expression": [tests.check_complex_has_dp]}
14@pytest.fixture
15def parser():
16 return get_fortran_parser()
19def test_other_function(parser, test_list):
20 code = b"y = myownfunction(a, b, dp)"
21 error_log = run_tests_on_code(parser, code, test_list, "filename")
22 assert len(error_log.errors) == 0
25def test_complex_dp_correct(parser, test_list):
26 code = b"y = CMPLX(a, b, dp)"
27 error_log = run_tests_on_code(parser, code, test_list, "filename")
28 assert len(error_log.errors) == 0
31def test_complex_dp_correct_keyword(parser, test_list):
32 code = b"y = CMPLX(z, kind=dp)"
33 error_log = run_tests_on_code(parser, code, test_list, "filename")
34 assert len(error_log.errors) == 0
37def test_complex_dp_wrong_place(parser, test_list):
38 code = b"y = CMPLX(z, dp)"
39 error_log = run_tests_on_code(parser, code, test_list, "filename")
40 assert len(error_log.errors) == 1
43def test_complex_dp_missing(parser, test_list):
44 code = b"y = CMPLX(a, b)"
45 error_log = run_tests_on_code(parser, code, test_list, "filename")
46 assert len(error_log.errors) == 1
49def test_complex_wrong_kind(parser, test_list):
50 code = b"y = CMPLX(a, b, x)"
51 error_log = run_tests_on_code(parser, code, test_list, "filename")
52 assert len(error_log.errors) == 1