Skip to content

Conversation

fatelei
Copy link

@fatelei fatelei commented Oct 12, 2025

gh-131178: add unittest for turtledemo command line interface

@bedevere-app bedevere-app bot added the tests Tests in the Lib/test dir label Oct 12, 2025
@bedevere-app

This comment was marked as resolved.

@fatelei fatelei force-pushed the turtledemo_ut branch 2 times, most recently from 45cb290 to d4e86b8 Compare October 12, 2025 05:23
@python python deleted a comment from bedevere-app bot Oct 12, 2025
@python python deleted a comment from bedevere-app bot Oct 12, 2025
@terryjreedy terryjreedy self-requested a review October 12, 2025 06:15
@python python deleted a comment from bedevere-app bot Oct 12, 2025
Copy link
Member

@StanFromIreland StanFromIreland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you creating a faux unittest? Please use the actual module, I suggest you look at the many other tests in Lib/test/.

Comment on lines +15 to +16
self.passed = 0
self.failed = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we tracking this manually? Unittest reports it automatically?

Comment on lines +18 to +56
def assert_true(self, condition, msg=""):
if condition:
self.passed += 1
print(f"✓ {msg}")
else:
self.failed += 1
print(f"✗ {msg}")

def assert_equal(self, a, b, msg=""):
if a == b:
self.passed += 1
print(f"✓ {msg}")
else:
self.failed += 1
print(f"✗ {msg}: {a} != {b}")

def assert_in(self, item, container, msg=""):
if item in container:
self.passed += 1
print(f"✓ {msg}")
else:
self.failed += 1
print(f"✗ {msg}: {item} not in {container}")

def assert_is_instance(self, obj, expected_type, msg=""):
if isinstance(obj, expected_type):
self.passed += 1
print(f"✓ {msg}")
else:
self.failed += 1
print(f"✗ {msg}: {type(obj)} != {expected_type}")

def assert_has_attr(self, obj, attr, msg=""):
if hasattr(obj, attr):
self.passed += 1
print(f"✓ {msg}")
else:
self.failed += 1
print(f"✗ {msg}: {attr} not found")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of these? Why not unittest methods, self.assertEqual, self.assertTrue and so on?

import importlib.util


class SimpleTest:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is unittest not used? Can you please look at existing tests.

Comment on lines +3 to +5
This test suite validates the CLI functionality of the turtledemo module,
which provides a GUI-based demo viewer for turtle graphics examples.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This test suite validates the CLI functionality of the turtledemo module,
which provides a GUI-based demo viewer for turtle graphics examples.

If we test more than the CLI, this comment is wrong, I suggest removing it now.

Comment on lines +58 to +61
def summary(self):
total = self.passed + self.failed
print(f"\nTest Summary: {self.passed}/{total} passed, {self.failed} failed")
return self.failed == 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for? Unittest provides such results automatically? This is not called anywhere in your test either?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants