22import os
33
44import pytest
5- import yaml
65
7- PLUGIN_DIR = os .path .join (os .path .dirname (__file__ ), '..' )
6+ yaml = pytest .importorskip ("yaml" )
7+
8+ PLUGIN_DIR = os .path .abspath (os .path .join (os .path .dirname (__file__ ), '..' ))
89REQUIREMENTS_PATH = os .path .join (PLUGIN_DIR , 'requirements.txt' )
910HOOK_PATH = os .path .join (PLUGIN_DIR , 'hook.py' )
1011CONF_DIR = os .path .join (PLUGIN_DIR , 'conf' )
@@ -21,7 +22,7 @@ def test_pyminizip_has_cve_warning_comment(self):
2122 in requirements.txt should warn maintainers about this risk so it
2223 is not overlooked during dependency reviews.
2324 """
24- with open (REQUIREMENTS_PATH , 'r' ) as f :
25+ with open (REQUIREMENTS_PATH , 'r' , encoding = 'utf-8' ) as f :
2526 content = f .read ()
2627
2728 # Verify pyminizip is listed
@@ -59,7 +60,7 @@ def test_hook_file_exists(self):
5960
6061 def test_hook_can_be_parsed (self ):
6162 """hook.py should be valid Python parseable by ast.parse."""
62- with open (HOOK_PATH , 'r' ) as f :
63+ with open (HOOK_PATH , 'r' , encoding = 'utf-8' ) as f :
6364 source = f .read ()
6465 try :
6566 tree = ast .parse (source )
@@ -69,7 +70,7 @@ def test_hook_can_be_parsed(self):
6970
7071 def test_hook_defines_enable_function (self ):
7172 """hook.py must define an async 'enable' function."""
72- with open (HOOK_PATH , 'r' ) as f :
73+ with open (HOOK_PATH , 'r' , encoding = 'utf-8' ) as f :
7374 source = f .read ()
7475 tree = ast .parse (source )
7576 enable_funcs = [
@@ -82,7 +83,7 @@ def test_hook_defines_enable_function(self):
8283
8384 def test_hook_defines_plugin_name (self ):
8485 """hook.py should define a 'name' variable."""
85- with open (HOOK_PATH , 'r' ) as f :
86+ with open (HOOK_PATH , 'r' , encoding = 'utf-8' ) as f :
8687 source = f .read ()
8788 tree = ast .parse (source )
8889 name_assignments = [
@@ -119,7 +120,7 @@ def test_conf_yaml_files_are_valid(self):
119120 f"No YAML files found in { CONF_DIR } "
120121 )
121122 for fpath in yaml_files :
122- with open (fpath , 'r' ) as f :
123+ with open (fpath , 'r' , encoding = 'utf-8' ) as f :
123124 try :
124125 data = yaml .safe_load (f )
125126 except yaml .YAMLError as e :
@@ -136,7 +137,7 @@ def test_data_yaml_files_are_valid_if_present(self):
136137 "No YAML files in data/ — run plugin setup to populate"
137138 )
138139 for fpath in yaml_files :
139- with open (fpath , 'r' ) as f :
140+ with open (fpath , 'r' , encoding = 'utf-8' ) as f :
140141 try :
141142 data = yaml .safe_load (f )
142143 except yaml .YAMLError as e :
0 commit comments