11import os
22import sys
33import unittest
4- from unittest .mock import MagicMock , patch
4+ import unittest .mock
5+ from unittest .mock import ANY , MagicMock , patch
56
67sys .path .insert (
78 0 , os .path .abspath (os .path .join (os .path .dirname (__file__ ), "../src" ))
@@ -42,14 +43,14 @@ class StubTextArea:
4243 def __init__ (self ):
4344 self .text = ""
4445
45- self .app .name_input = StubInput ()
46- self .app .email_input = StubInput ()
47- self .app .city_input = StubInput ()
48- self .app .homepage_input = StubInput ()
49- self .app .who_area = StubTextArea ()
50- self .app .python_area = StubTextArea ()
51- self .app .contributions_area = StubTextArea ()
52- self .app .availability_area = StubTextArea ()
46+ self .app .name_input = StubInput () # type: ignore
47+ self .app .email_input = StubInput () # type: ignore
48+ self .app .city_input = StubInput () # type: ignore
49+ self .app .homepage_input = StubInput () # type: ignore
50+ self .app .who_area = StubTextArea () # type: ignore
51+ self .app .python_area = StubTextArea () # type: ignore
52+ self .app .contributions_area = StubTextArea () # type: ignore
53+ self .app .availability_area = StubTextArea () # type: ignore
5354
5455 # Patch remove method for entries to avoid Textual lifecycle errors
5556 # Use stub classes for entries with .remove() method
@@ -76,18 +77,18 @@ def remove(self):
7677 def test_add_social_entry (self ):
7778 # Patch add_social_entry to use stub
7879 self .app .social_entries = []
79- self .app .social_container .mount = MagicMock ()
80+ self .app .social_container .mount = MagicMock () # type: ignore
8081 # Patch mount to accept any object
8182 self .app .social_container .mount = lambda x : None # type: ignore
8283
8384 def stub_add_social_entry (value ):
8485 entry = self .StubSocialEntry ()
8586 entry .index = self .app .social_index
8687 self .app .social_index += 1
87- self .app .social_entries .append (entry )
88- self .app .social_container .mount (entry )
88+ self .app .social_entries .append (entry ) # type: ignore
89+ self .app .social_container .mount (entry ) # type: ignore
8990
90- self .app .add_social_entry = stub_add_social_entry
91+ self .app .add_social_entry = stub_add_social_entry # type: ignore
9192 initial_count = len (self .app .social_entries )
9293 self .app .add_social_entry ("" )
9394 self .assertEqual (len (self .app .social_entries ), initial_count + 1 )
@@ -104,8 +105,8 @@ def test_add_list_button_clears_form(self):
104105 self .app .contributions_area .text = "Filled Contributions"
105106 self .app .availability_area .text = "Filled Available"
106107 # Add social and alias entries
107- self .app .social_entries = [self .StubSocialEntry ()]
108- self .app .alias_entries = [self .StubAliasEntry ()]
108+ self .app .social_entries = [self .StubSocialEntry ()] # type: ignore
109+ self .app .alias_entries = [self .StubAliasEntry ()] # type: ignore
109110
110111 # Simulate pressing the 'Añadir' button on the list screen
111112 class DummyButton :
@@ -114,7 +115,7 @@ class DummyButton:
114115 class DummyEvent :
115116 button = DummyButton ()
116117
117- self .app .on_button_pressed (DummyEvent ())
118+ self .app .on_button_pressed (DummyEvent ()) # type: ignore
118119 # After pressing, form should be cleared and current_file should be None
119120 self .assertEqual (self .app .name_input .value , "" )
120121 self .assertEqual (self .app .email_input .value , "" )
@@ -137,18 +138,18 @@ class DummyEvent:
137138 def test_add_alias_entry (self ):
138139 # Patch add_alias_entry to use stub
139140 self .app .alias_entries = []
140- self .app .alias_container .mount = MagicMock ()
141+ self .app .alias_container .mount = MagicMock () # type: ignore
141142 # Patch mount to accept any object
142143 self .app .alias_container .mount = lambda x : None # type: ignore
143144
144145 def stub_add_alias_entry ():
145146 entry = self .StubAliasEntry ()
146147 entry .index = self .app .alias_index
147148 self .app .alias_index += 1
148- self .app .alias_entries .append (entry )
149- self .app .alias_container .mount (entry )
149+ self .app .alias_entries .append (entry ) # type: ignore
150+ self .app .alias_container .mount (entry ) # type: ignore
150151
151- self .app .add_alias_entry = stub_add_alias_entry
152+ self .app .add_alias_entry = stub_add_alias_entry # type: ignore
152153 initial_count = len (self .app .alias_entries )
153154 self .app .add_alias_entry ()
154155 self .assertEqual (len (self .app .alias_entries ), initial_count + 1 )
@@ -354,18 +355,18 @@ def stub_add_social_entry(value):
354355 entry = self .StubSocialEntry ()
355356 entry .index = self .app .social_index
356357 self .app .social_index += 1
357- self .app .social_entries .append (entry )
358- self .app .social_container .mount (entry )
358+ self .app .social_entries .append (entry ) # type: ignore
359+ self .app .social_container .mount (entry ) # type: ignore
359360
360361 def stub_add_alias_entry ():
361362 entry = self .StubAliasEntry ()
362363 entry .index = self .app .alias_index
363364 self .app .alias_index += 1
364- self .app .alias_entries .append (entry )
365- self .app .alias_container .mount (entry )
365+ self .app .alias_entries .append (entry ) # type: ignore
366+ self .app .alias_container .mount (entry ) # type: ignore
366367
367- self .app .add_social_entry = stub_add_social_entry
368- self .app .add_alias_entry = stub_add_alias_entry
368+ self .app .add_social_entry = stub_add_social_entry # type: ignore
369+ self .app .add_alias_entry = stub_add_alias_entry # type: ignore
369370 self .app .add_social_entry ("" )
370371 self .app .add_alias_entry ()
371372 self .app .clear_form ()
@@ -411,18 +412,18 @@ def stub_add_social_entry(value):
411412 entry = self .StubSocialEntry ()
412413 entry .index = self .app .social_index
413414 self .app .social_index += 1
414- self .app .social_entries .append (entry )
415- self .app .social_container .mount (entry )
415+ self .app .social_entries .append (entry ) # type: ignore
416+ self .app .social_container .mount (entry ) # type: ignore
416417
417418 def stub_add_alias_entry ():
418419 entry = self .StubAliasEntry ()
419420 entry .index = self .app .alias_index
420421 self .app .alias_index += 1
421- self .app .alias_entries .append (entry )
422- self .app .alias_container .mount (entry )
422+ self .app .alias_entries .append (entry ) # type: ignore
423+ self .app .alias_container .mount (entry ) # type: ignore
423424
424- self .app .add_social_entry = stub_add_social_entry
425- self .app .add_alias_entry = stub_add_alias_entry
425+ self .app .add_social_entry = stub_add_social_entry # type: ignore
426+ self .app .add_alias_entry = stub_add_alias_entry # type: ignore
426427 # Patch clear_form to avoid resetting stubs
427428 self .app .clear_form = lambda : None # type: ignore
428429 load_file_into_form (self .app , "fake.md" )
@@ -468,9 +469,9 @@ def test_main_runs_app(
468469 mock_get_repo .assert_called_once ()
469470 mock_fork_repo .assert_called_once ()
470471 mock_member_app .assert_called_once_with (
471- unittest . mock . ANY ,
472- unittest . mock . ANY ,
473- unittest . mock . ANY ,
474- unittest . mock . ANY ,
472+ ANY ,
473+ ANY ,
474+ ANY ,
475+ ANY ,
475476 )
476477 mock_app_instance .run .assert_called_once ()
0 commit comments