66it under the terms of the GNU General Public License as published by
77the Free Software Foundation, version 3 of the License.
88"""
9- #pylint: disable=import-error, invalid-name, unused-argument, wrong-import-position, import-outside-toplevel
9+
10+ # pylint: disable=import-error, invalid-name, unused-argument, wrong-import-position, import-outside-toplevel
1011
1112import unittest
1213from unittest .mock import Mock , patch , mock_open
1314import os
1415import sys
1516
1617# Add parent directory to path for imports
17- sys .path .insert (0 , os .path .abspath (os .path .join (os .path .dirname (__file__ ), '..' )))
18+ sys .path .insert (0 , os .path .abspath (os .path .join (os .path .dirname (__file__ ), ".." )))
1819
1920from main import openLicense , openEULA , ProgramVer , get_resource_path
2021
@@ -42,9 +43,11 @@ def test_get_resource_path_handles_subdirectories(self):
4243class TestOpenLicense (unittest .TestCase ):
4344 """Test cases for openLicense function."""
4445
45- @patch ('main.Text' )
46- @patch ('main.Tk' )
47- @patch ('builtins.open' , new_callable = mock_open , read_data = 'GNU GENERAL PUBLIC LICENSE' )
46+ @patch ("main.Text" )
47+ @patch ("main.Tk" )
48+ @patch (
49+ "builtins.open" , new_callable = mock_open , read_data = "GNU GENERAL PUBLIC LICENSE"
50+ )
4851 def test_openLicense_creates_window (self , mock_file , mock_tk , mock_text ):
4952 """Test that openLicense creates a window and reads LICENSE.txt."""
5053 mock_window = Mock ()
@@ -63,9 +66,9 @@ def test_openLicense_creates_window(self, mock_file, mock_tk, mock_text):
6366 # Verify window title was set
6467 mock_window .title .assert_called_once_with ("License" )
6568
66- @patch (' main.Tk' )
67- @patch (' builtins.open' , new_callable = mock_open , read_data = ' Test License Content' )
68- @patch (' main.Text' )
69+ @patch (" main.Tk" )
70+ @patch (" builtins.open" , new_callable = mock_open , read_data = " Test License Content" )
71+ @patch (" main.Text" )
6972 def test_openLicense_displays_content (self , mock_text , mock_file , mock_tk ):
7073 """Test that openLicense displays license content."""
7174 mock_window = Mock ()
@@ -86,9 +89,11 @@ def test_openLicense_displays_content(self, mock_text, mock_file, mock_tk):
8689class TestOpenEULA (unittest .TestCase ):
8790 """Test cases for openEULA function."""
8891
89- @patch ('main.Text' )
90- @patch ('main.Tk' )
91- @patch ('builtins.open' , new_callable = mock_open , read_data = 'END USER LICENSE AGREEMENT' )
92+ @patch ("main.Text" )
93+ @patch ("main.Tk" )
94+ @patch (
95+ "builtins.open" , new_callable = mock_open , read_data = "END USER LICENSE AGREEMENT"
96+ )
9297 def test_openEULA_creates_window (self , mock_file , mock_tk , mock_text ):
9398 """Test that openEULA creates a window and reads EULA.txt."""
9499 mock_window = Mock ()
@@ -107,9 +112,9 @@ def test_openEULA_creates_window(self, mock_file, mock_tk, mock_text):
107112 # Verify window title was set
108113 mock_window .title .assert_called_once_with ("EULA" )
109114
110- @patch (' main.Tk' )
111- @patch (' builtins.open' , new_callable = mock_open , read_data = ' Test EULA Content' )
112- @patch (' main.Text' )
115+ @patch (" main.Tk" )
116+ @patch (" builtins.open" , new_callable = mock_open , read_data = " Test EULA Content" )
117+ @patch (" main.Text" )
113118 def test_openEULA_displays_content (self , mock_text , mock_file , mock_tk ):
114119 """Test that openEULA displays EULA content."""
115120 mock_window = Mock ()
@@ -130,11 +135,13 @@ def test_openEULA_displays_content(self, mock_text, mock_file, mock_tk):
130135class TestProgramVer (unittest .TestCase ):
131136 """Test cases for ProgramVer function."""
132137
133- @patch ('main.Tk' )
134- @patch ('main.PhotoImage' )
135- @patch ('main.Label' )
136- @patch ('main.Button' )
137- def test_programver_creates_window (self , mock_button , mock_label , mock_photoimage , mock_tk ):
138+ @patch ("main.Tk" )
139+ @patch ("main.PhotoImage" )
140+ @patch ("main.Label" )
141+ @patch ("main.Button" )
142+ def test_programver_creates_window (
143+ self , mock_button , mock_label , mock_photoimage , mock_tk
144+ ):
138145 """Test that ProgramVer creates main window with all components."""
139146 mock_window = Mock ()
140147 mock_tk .return_value = mock_window
@@ -152,11 +159,13 @@ def test_programver_creates_window(self, mock_button, mock_label, mock_photoimag
152159 mock_window .title .assert_called_once ()
153160 assert "ProgramVer" in str (mock_window .title .call_args )
154161
155- @patch ('main.Tk' )
156- @patch ('main.PhotoImage' )
157- @patch ('main.Label' )
158- @patch ('main.Button' )
159- def test_programver_loads_images (self , mock_button , mock_label , mock_photoimage , mock_tk ):
162+ @patch ("main.Tk" )
163+ @patch ("main.PhotoImage" )
164+ @patch ("main.Label" )
165+ @patch ("main.Button" )
166+ def test_programver_loads_images (
167+ self , mock_button , mock_label , mock_photoimage , mock_tk
168+ ):
160169 """Test that ProgramVer loads required images."""
161170 mock_window = Mock ()
162171 mock_tk .return_value = mock_window
@@ -168,15 +177,17 @@ def test_programver_loads_images(self, mock_button, mock_label, mock_photoimage,
168177 assert mock_photoimage .call_count == 2
169178 # Check that both images are loaded with absolute paths
170179 calls = mock_photoimage .call_args_list
171- image_files = [call [1 ][' file' ] for call in calls ]
180+ image_files = [call [1 ][" file" ] for call in calls ]
172181 assert any ("dfdlogo.gif" in img for img in image_files )
173182 assert any ("pythonpoweredlengthgif.gif" in img for img in image_files )
174183
175- @patch ('main.Tk' )
176- @patch ('main.PhotoImage' )
177- @patch ('main.Label' )
178- @patch ('main.Button' )
179- def test_programver_creates_labels (self , mock_button , mock_label , mock_photoimage , mock_tk ):
184+ @patch ("main.Tk" )
185+ @patch ("main.PhotoImage" )
186+ @patch ("main.Label" )
187+ @patch ("main.Button" )
188+ def test_programver_creates_labels (
189+ self , mock_button , mock_label , mock_photoimage , mock_tk
190+ ):
180191 """Test that ProgramVer creates appropriate labels."""
181192 mock_window = Mock ()
182193 mock_tk .return_value = mock_window
@@ -188,11 +199,13 @@ def test_programver_creates_labels(self, mock_button, mock_label, mock_photoimag
188199 assert mock_label .call_count >= 5
189200 # Verify labels were created with window
190201
191- @patch ('main.Tk' )
192- @patch ('main.PhotoImage' )
193- @patch ('main.Label' )
194- @patch ('main.Button' )
195- def test_programver_creates_buttons (self , mock_button , mock_label , mock_photoimage , mock_tk ):
202+ @patch ("main.Tk" )
203+ @patch ("main.PhotoImage" )
204+ @patch ("main.Label" )
205+ @patch ("main.Button" )
206+ def test_programver_creates_buttons (
207+ self , mock_button , mock_label , mock_photoimage , mock_tk
208+ ):
196209 """Test that ProgramVer creates license and EULA buttons."""
197210 mock_window = Mock ()
198211 mock_tk .return_value = mock_window
@@ -204,15 +217,17 @@ def test_programver_creates_buttons(self, mock_button, mock_label, mock_photoima
204217 assert mock_button .call_count == 2
205218 # Verify buttons have correct text and commands
206219 calls = mock_button .call_args_list
207- button_texts = [call [1 ][' text' ] for call in calls ]
220+ button_texts = [call [1 ][" text" ] for call in calls ]
208221 assert "Open License" in button_texts
209222 assert "Open EULA" in button_texts
210223
211- @patch ('main.Tk' )
212- @patch ('main.PhotoImage' )
213- @patch ('main.Label' )
214- @patch ('main.Button' )
215- def test_programver_button_commands (self , mock_button , mock_label , mock_photoimage , mock_tk ):
224+ @patch ("main.Tk" )
225+ @patch ("main.PhotoImage" )
226+ @patch ("main.Label" )
227+ @patch ("main.Button" )
228+ def test_programver_button_commands (
229+ self , mock_button , mock_label , mock_photoimage , mock_tk
230+ ):
216231 """Test that buttons are linked to correct command functions."""
217232 mock_window = Mock ()
218233 mock_tk .return_value = mock_window
@@ -221,7 +236,7 @@ def test_programver_button_commands(self, mock_button, mock_label, mock_photoima
221236 ProgramVer ()
222237
223238 calls = mock_button .call_args_list
224- commands = [call [1 ].get (' command' ) for call in calls ]
239+ commands = [call [1 ].get (" command" ) for call in calls ]
225240 # Verify that openLicense and openEULA are set as commands
226241 assert openLicense in commands
227242 assert openEULA in commands
@@ -233,19 +248,21 @@ class TestModuleIntegration(unittest.TestCase):
233248 def test_module_imports (self ):
234249 """Test that the main module can be imported successfully."""
235250 import main
236- assert hasattr (main , 'ProgramVer' )
237- assert hasattr (main , 'openLicense' )
238- assert hasattr (main , 'openEULA' )
239- assert hasattr (main , 'get_resource_path' )
251+
252+ assert hasattr (main , "ProgramVer" )
253+ assert hasattr (main , "openLicense" )
254+ assert hasattr (main , "openEULA" )
255+ assert hasattr (main , "get_resource_path" )
240256
241257 def test_functions_are_callable (self ):
242258 """Test that all exported functions are callable."""
243259 import main
260+
244261 assert callable (main .ProgramVer )
245262 assert callable (main .openLicense )
246263 assert callable (main .openEULA )
247264 assert callable (main .get_resource_path )
248265
249266
250- if __name__ == ' __main__' :
267+ if __name__ == " __main__" :
251268 unittest .main ()
0 commit comments