Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving unit tests assertion messages #2275

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Pythonwin/pywin/Demos/openGLDemo.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ def _DestroyContexts(self):

# The methods to support OpenGL
def DrawScene(self):
assert 0, "You must override this method"
raise NotImplementedError("You must override this method")

def Init(self):
assert 0, "You must override this method"
raise NotImplementedError("You must override this method")

def OnSizeChange(self, cx, cy):
pass
Expand Down
4 changes: 2 additions & 2 deletions Pythonwin/pywin/debugger/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ def set_cur_frame(self, frame):
self.curindex = index
break
else:
assert 0, "Can't find the frame in the stack."
assert False, "Can't find the frame in the stack."
SetInteractiveContext(frame.f_globals, frame.f_locals)
self.GUIRespondDebuggerData()
self.ShowCurrentLine()
Expand Down Expand Up @@ -931,7 +931,7 @@ def GetDebuggerBar(self, barName):
for id, klass, float in DebuggerDialogInfos:
if klass.title == barName:
return frame.GetControlBar(id)
assert 0, "Can't find a bar of that name!"
assert False, "Can't find a bar of that name!"

def GUIRespondDebuggerData(self):
if not self.inited: # GUI not inited - no toolbars etc.
Expand Down
5 changes: 2 additions & 3 deletions Pythonwin/pywin/framework/editor/template.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os

import pywin.framework.window
import win32api
import win32ui
from pywin.mfc import docview
Expand All @@ -19,10 +18,10 @@ def __init__(
ParentEditorTemplate.__init__(self, res, makeDoc, makeFrame, makeView)

def _CreateDocTemplate(self, resourceId):
assert 0, "You must override this"
raise NotImplementedError("You must override this")

def CreateWin32uiDocument(self):
assert 0, "You must override this"
raise NotImplementedError("You must override this")

def GetFileExtensions(self):
return ".txt", ".py"
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/idle/AutoIndent.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def newline_and_indent_event(self, event):
else:
self.reindent_to(y.compute_backslash_indent())
else:
assert 0, "bogus continuation type " + repr(c)
raise ValueError(f"bogus continuation type {c!r}")
return "break"

# This line starts a brand new stmt; indent relative to
Expand Down
6 changes: 3 additions & 3 deletions Pythonwin/pywin/test/test_exe.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def setUp(self):
dst = os.path.dirname(pythonwinexe_path) + os.sep + pydll
if not os.path.isfile(dst):
try:
assert os.path.isfile(src)
self.assertTrue(os.path.isfile(src))
print(f"-- symlink {dst!r} -> {src!r}", file=sys.stderr)
os.symlink(src, dst)
except (OSError, AssertionError) as e:
Expand All @@ -62,8 +62,8 @@ def test_exe(self):
rc = "TIMEOUT"
with open(self.tfn) as f:
outs = f.read()
assert rc == 0, f"rc is {rc!r}, outs={outs!r}"
assert "Success!" in outs, outs
self.assertEqual(rc, 0, f"outs={outs!r}")
self.assertIn("Success!", outs)
print("-- test_exe Ok! --", file=sys.stderr)

def tearDown(self):
Expand Down
Loading
Loading