55from types import ModuleType
66from unittest .mock import patch
77
8+ from typing import Any
9+
810import pytest
911
1012from utils import checks
1113
1214
1315@pytest .fixture (name = "input_file" )
14- def input_file_fixture (tmp_path ) :
16+ def input_file_fixture (tmp_path : Path ) -> str :
1517 """Create file manually using the tmp_path fixture."""
1618 filename = os .path .join (tmp_path , "mydoc.csv" )
1719 with open (filename , "wt" , encoding = "utf-8" ) as fout :
@@ -20,17 +22,17 @@ def input_file_fixture(tmp_path):
2022
2123
2224@pytest .fixture (name = "input_directory" )
23- def input_directory_fixture (tmp_path ) :
25+ def input_directory_fixture (tmp_path : Path ) -> str :
2426 """Create directory manually using the tmp_path fixture."""
2527 dirname = os .path .join (tmp_path , "mydir" )
2628 os .mkdir (dirname )
2729 return dirname
2830
2931
30- def test_get_attribute_from_file_no_record ():
32+ def test_get_attribute_from_file_no_record () -> None :
3133 """Test the get_attribute_from_file function when record is not in dictionary."""
3234 # no data
33- d = {}
35+ d : dict [ str , Any ] = {}
3436
3537 # non-existing key
3638 key = ""
@@ -43,7 +45,7 @@ def test_get_attribute_from_file_no_record():
4345 assert value is None
4446
4547
46- def test_get_attribute_from_file_proper_record (input_file ) :
48+ def test_get_attribute_from_file_proper_record (input_file : str ) -> None :
4749 """Test the get_attribute_from_file function when record is present in dictionary."""
4850 # existing key
4951 key = "my_file"
@@ -57,7 +59,7 @@ def test_get_attribute_from_file_proper_record(input_file):
5759 assert value == "some content!"
5860
5961
60- def test_get_attribute_from_file_improper_filename ():
62+ def test_get_attribute_from_file_improper_filename () -> None :
6163 """Test the get_attribute_from_file when the file does not exist."""
6264 # existing key
6365 key = "my_file"
@@ -70,26 +72,26 @@ def test_get_attribute_from_file_improper_filename():
7072 checks .get_attribute_from_file (d , "my_file" )
7173
7274
73- def test_file_check_existing_file (input_file ) :
75+ def test_file_check_existing_file (input_file : str ) -> None :
7476 """Test the function file_check for existing file."""
7577 # just call the function, it should not raise an exception
7678 checks .file_check (input_file , "description" )
7779
7880
79- def test_file_check_non_existing_file ():
81+ def test_file_check_non_existing_file () -> None :
8082 """Test the function file_check for non existing file."""
8183 with pytest .raises (checks .InvalidConfigurationError ):
8284 checks .file_check (Path ("does-not-exists" ), "description" )
8385
8486
85- def test_file_check_not_readable_file (input_file ) :
87+ def test_file_check_not_readable_file (input_file : str ) -> None :
8688 """Test the function file_check for not readable file."""
8789 with patch ("os.access" , return_value = False ):
8890 with pytest .raises (checks .InvalidConfigurationError ):
8991 checks .file_check (input_file , "description" )
9092
9193
92- def test_directory_check_non_existing_directory ():
94+ def test_directory_check_non_existing_directory () -> None :
9395 """Test the function directory_check skips non-existing directory."""
9496 # just call the function, it should not raise an exception
9597 checks .directory_check (
@@ -101,15 +103,15 @@ def test_directory_check_non_existing_directory():
101103 )
102104
103105
104- def test_directory_check_existing_writable_directory (input_directory ) :
106+ def test_directory_check_existing_writable_directory (input_directory : str ) -> None :
105107 """Test the function directory_check checks directory."""
106108 # just call the function, it should not raise an exception
107109 checks .directory_check (
108110 input_directory , must_exists = True , must_be_writable = True , desc = "foobar"
109111 )
110112
111113
112- def test_directory_check_non_a_directory (input_file ) :
114+ def test_directory_check_non_a_directory (input_file : str ) -> None :
113115 """Test the function directory_check checks directory."""
114116 # pass a filename not a directory name
115117 with pytest .raises (checks .InvalidConfigurationError ):
@@ -118,7 +120,7 @@ def test_directory_check_non_a_directory(input_file):
118120 )
119121
120122
121- def test_directory_check_existing_non_writable_directory (input_directory ) :
123+ def test_directory_check_existing_non_writable_directory (input_directory : str ) -> None :
122124 """Test the function directory_check checks directory."""
123125 with patch ("os.access" , return_value = False ):
124126 with pytest .raises (checks .InvalidConfigurationError ):
@@ -127,7 +129,7 @@ def test_directory_check_existing_non_writable_directory(input_directory):
127129 )
128130
129131
130- def test_import_python_module_success ():
132+ def test_import_python_module_success () -> None :
131133 """Test importing a Python module."""
132134 module_path = "tests/profiles/test/profile.py"
133135 module_name = "profile"
@@ -136,7 +138,7 @@ def test_import_python_module_success():
136138 assert isinstance (result , ModuleType )
137139
138140
139- def test_import_python_module_error ():
141+ def test_import_python_module_error () -> None :
140142 """Test importing a Python module that is a .txt file."""
141143 module_path = "tests/profiles/test_two/test.txt"
142144 module_name = "profile"
@@ -145,7 +147,7 @@ def test_import_python_module_error():
145147 assert result is None
146148
147149
148- def test_is_valid_profile ():
150+ def test_is_valid_profile () -> None :
149151 """Test if an imported profile is valid."""
150152 module_path = "tests/profiles/test/profile.py"
151153 module_name = "profile"
@@ -157,7 +159,7 @@ def test_is_valid_profile():
157159 assert result is True
158160
159161
160- def test_invalid_profile ():
162+ def test_invalid_profile () -> None :
161163 """Test if an imported profile is valid (expect invalid)"""
162164 module_path = "tests/profiles/test_three/profile.py"
163165 module_name = "profile"
0 commit comments