mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-08-03 20:54:25 -07:00
fix warning baseexception class error
This commit is contained in:
parent
4b14ac1b50
commit
12a95c4446
3 changed files with 17 additions and 13 deletions
|
@ -19,22 +19,22 @@ class dummy_cursor_class():
|
|||
return [self.output]
|
||||
|
||||
|
||||
class MockCursor:
|
||||
Warning = None
|
||||
# Define MockWarning at module level to ensure it's a proper exception class
|
||||
class MockWarning(Exception):
|
||||
pass
|
||||
|
||||
def __init__(self, status="ONLINE", warning=None):
|
||||
|
||||
class MockCursor:
|
||||
# Set the Warning class at the class level
|
||||
Warning = MockWarning
|
||||
|
||||
def __init__(self, status="ONLINE"):
|
||||
self.status = status
|
||||
self.executed_queries = []
|
||||
self.Warning = warning
|
||||
|
||||
def execute(self, query):
|
||||
self.executed_queries.append(query)
|
||||
if self.status == "ERROR":
|
||||
# Create a custom exception that mimics mysql_driver.Warning
|
||||
class MockWarning(Exception):
|
||||
pass
|
||||
# Make it available as a class attribute for tests to use
|
||||
MockCursor.Warning = MockWarning
|
||||
raise MockWarning("Mocked execution error")
|
||||
|
||||
def fetchone(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue