@@ -177,15 +177,19 @@ class ExternalTestMixin(_Base):
177177 """A cmd2 plugin (mixin class) that exposes an interface to execute application commands from python"""
178178
179179 def __init__ (self , * args , ** kwargs ):
180- """
180+ """Initializes the ExternalTestMixin.
181+
182+ This class is intended to be used in multiple inheritance alongside `cmd2.Cmd` for an application class.
183+ When doing this multiple inheritance, it is imperative that this mixin class come first.
181184
182185 :type self: cmd2.Cmd
183- :param args:
184- :param kwargs:
186+ :param args: arguments to pass to the superclass
187+ :param kwargs: keyword arguments to pass to the superclass
185188 """
186189 # code placed here runs before cmd2 initializes
187190 super ().__init__ (* args , ** kwargs )
188- assert isinstance (self , cmd2 .Cmd )
191+ if not isinstance (self , cmd2 .Cmd ):
192+ raise TypeError ('The ExternalTestMixin class is intended to be used in multiple inhertance with cmd2.Cmd' )
189193 # code placed here runs after cmd2 initializes
190194 self ._pybridge = cmd2 .py_bridge .PyBridge (self )
191195
@@ -197,19 +201,19 @@ def app_cmd(self, command: str, echo: bool | None = None) -> cmd2.CommandResult:
197201 :param echo: Flag whether the command's output should be echoed to stdout/stderr
198202 :return: A CommandResult object that captures stdout, stderr, and the command's result object
199203 """
200- assert isinstance (self , cmd2 .Cmd )
201- assert isinstance (self , ExternalTestMixin )
202204 try :
203205 self ._in_py = True
204-
205206 return self ._pybridge (command , echo = echo )
206207
207208 finally :
208209 self ._in_py = False
209210
210211 def fixture_setup (self ):
211- """
212- Replicates the behavior of `cmdloop()` preparing the state of the application
212+ """Replicates the behavior of `cmdloop()` to prepare the application state for testing.
213+
214+ This method runs all preloop hooks and the preloop method to ensure the
215+ application is in the correct state before running a test.
216+
213217 :type self: cmd2.Cmd
214218 """
215219
@@ -218,8 +222,10 @@ def fixture_setup(self):
218222 self .preloop ()
219223
220224 def fixture_teardown (self ):
221- """
222- Replicates the behavior of `cmdloop()` tearing down the application
225+ """Replicates the behavior of `cmdloop()` to tear down the application after a test.
226+
227+ This method runs all postloop hooks and the postloop method to clean up
228+ the application state and ensure test isolation.
223229
224230 :type self: cmd2.Cmd
225231 """
0 commit comments