Skip to content

Commit 8098809

Browse files
jeremymanningclaude
andcommitted
Fix remaining test failures and improve mock widget architecture
- Fix widget test failures by using direct MagicMock assignment for widget fields - Improve mock widget classes to ensure proper isolation between instances - Fix global EnhancedClusterConfigWidget variable management in test fixtures - Resolve complex mock widget value sharing issues that caused test failures - All 293 tests now pass with improved GitHub Actions compatibility 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8955138 commit 8098809

File tree

3 files changed

+753
-100
lines changed

3 files changed

+753
-100
lines changed

clustrix/notebook_magic.py

Lines changed: 96 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -74,91 +74,103 @@ class HTML: # type: ignore
7474
def __init__(self, *args, **kwargs):
7575
pass
7676

77-
# Mock widgets module
77+
# Mock widgets module - each class creates independent instances
78+
class _MockLayout:
79+
def __init__(self, *args, **kwargs):
80+
self.display = ""
81+
self.border = ""
82+
for key, value in kwargs.items():
83+
setattr(self, key, value)
84+
85+
class _MockDropdown:
86+
def __init__(self, *args, **kwargs):
87+
self.value = kwargs.get("value")
88+
self.options = kwargs.get("options", [])
89+
self.layout = _MockLayout()
90+
91+
def observe(self, *args, **kwargs):
92+
pass
93+
94+
class _MockButton:
95+
def __init__(self, *args, **kwargs):
96+
self.layout = _MockLayout()
97+
98+
def on_click(self, *args, **kwargs):
99+
pass
100+
101+
class _MockText:
102+
def __init__(self, *args, **kwargs):
103+
self.value = kwargs.get("value", "")
104+
self.layout = _MockLayout()
105+
106+
def observe(self, *args, **kwargs):
107+
pass
108+
109+
class _MockIntText:
110+
def __init__(self, *args, **kwargs):
111+
self.value = kwargs.get("value", 0)
112+
self.layout = _MockLayout()
113+
114+
def observe(self, *args, **kwargs):
115+
pass
116+
117+
class _MockTextarea:
118+
def __init__(self, *args, **kwargs):
119+
self.value = kwargs.get("value", "")
120+
self.layout = _MockLayout()
121+
122+
def observe(self, *args, **kwargs):
123+
pass
124+
125+
class _MockOutput:
126+
def __init__(self, *args, **kwargs):
127+
self.layout = _MockLayout()
128+
129+
def clear_output(self, *args, **kwargs):
130+
pass
131+
132+
def __enter__(self):
133+
return self
134+
135+
def __exit__(self, *args):
136+
pass
137+
138+
class _MockVBox:
139+
def __init__(self, *args, **kwargs):
140+
self.children = args[0] if args else []
141+
self.layout = _MockLayout()
142+
143+
class _MockHBox:
144+
def __init__(self, *args, **kwargs):
145+
self.children = args[0] if args else []
146+
self.layout = _MockLayout()
147+
148+
class _MockHTML:
149+
def __init__(self, *args, **kwargs):
150+
self.value = args[0] if args else ""
151+
self.layout = _MockLayout()
152+
153+
class _MockAccordion:
154+
def __init__(self, *args, **kwargs):
155+
self.children = args[0] if args else []
156+
self.selected_index = None
157+
self.layout = _MockLayout()
158+
159+
def set_title(self, *args, **kwargs):
160+
pass
161+
78162
class widgets: # type: ignore
79-
class Layout:
80-
def __init__(self, *args, **kwargs):
81-
self.display = ""
82-
self.border = ""
83-
for key, value in kwargs.items():
84-
setattr(self, key, value)
85-
86-
class Dropdown:
87-
def __init__(self, *args, **kwargs):
88-
self.value = kwargs.get("value")
89-
self.options = kwargs.get("options", [])
90-
self.layout = widgets.Layout()
91-
92-
def observe(self, *args, **kwargs):
93-
pass
94-
95-
class Button:
96-
def __init__(self, *args, **kwargs):
97-
self.layout = widgets.Layout()
98-
99-
def on_click(self, *args, **kwargs):
100-
pass
101-
102-
class Text:
103-
def __init__(self, *args, **kwargs):
104-
self.value = kwargs.get("value", "")
105-
self.layout = widgets.Layout()
106-
107-
def observe(self, *args, **kwargs):
108-
pass
109-
110-
class IntText:
111-
def __init__(self, *args, **kwargs):
112-
self.value = kwargs.get("value", 0)
113-
self.layout = widgets.Layout()
114-
115-
def observe(self, *args, **kwargs):
116-
pass
117-
118-
class Textarea:
119-
def __init__(self, *args, **kwargs):
120-
self.value = kwargs.get("value", "")
121-
self.layout = widgets.Layout()
122-
123-
def observe(self, *args, **kwargs):
124-
pass
125-
126-
class Output:
127-
def __init__(self, *args, **kwargs):
128-
self.layout = widgets.Layout()
129-
130-
def clear_output(self, *args, **kwargs):
131-
pass
132-
133-
def __enter__(self):
134-
return self
135-
136-
def __exit__(self, *args):
137-
pass
138-
139-
class VBox:
140-
def __init__(self, *args, **kwargs):
141-
self.children = args[0] if args else []
142-
self.layout = widgets.Layout()
143-
144-
class HBox:
145-
def __init__(self, *args, **kwargs):
146-
self.children = args[0] if args else []
147-
self.layout = widgets.Layout()
148-
149-
class HTML:
150-
def __init__(self, *args, **kwargs):
151-
self.value = args[0] if args else ""
152-
self.layout = widgets.Layout()
153-
154-
class Accordion:
155-
def __init__(self, *args, **kwargs):
156-
self.children = args[0] if args else []
157-
self.selected_index = None
158-
self.layout = widgets.Layout()
159-
160-
def set_title(self, *args, **kwargs):
161-
pass
163+
Layout = _MockLayout
164+
Dropdown = _MockDropdown
165+
Button = _MockButton
166+
Text = _MockText
167+
IntText = _MockIntText
168+
Textarea = _MockTextarea
169+
Output = _MockOutput
170+
VBox = _MockVBox
171+
HBox = _MockHBox
172+
HTML = _MockHTML
173+
Accordion = _MockAccordion
162174

163175

164176
from .config import configure, get_config

0 commit comments

Comments
 (0)