Skip to content

Add assertTStringEqual() helper #73

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

Merged
merged 6 commits into from
Apr 21, 2025

Conversation

AA-Turner
Copy link

@AA-Turner AA-Turner commented Apr 19, 2025

cc @lysnikolaou

The tests are currently very verbose, as each attribute of each interpolation needs to be tested individually. This PR introduces a helper function to assert that a t-string is equal to a tuple of strings and a sequence of interpolation tuples.

A

@AA-Turner AA-Turner requested a review from lysnikolaou as a code owner April 19, 2025 16:27
Copy link
Owner

@lysnikolaou lysnikolaou left a comment

Choose a reason for hiding this comment

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

This is a good improvement. Not sure if it'll work as is though.

for actual, expected in zip(t.interpolations, interpolations,
strict=True):
if len(expected) == 2:
self.assertEqual(tuple(actual), expected + (None, ''))
Copy link
Owner

@lysnikolaou lysnikolaou Apr 19, 2025

Choose a reason for hiding this comment

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

I don't think the tuple(actual) call will work since Interpolation is not iterable.

Copy link
Author

Choose a reason for hiding this comment

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

Of course, sorry -- I wrote this on a computer without a working build of the branch. I've pushed a fix.

Copy link
Owner

@lysnikolaou lysnikolaou left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @AA-Turner!

@lysnikolaou lysnikolaou merged commit fb68d60 into lysnikolaou:tstrings Apr 21, 2025
3 checks passed
@AA-Turner AA-Turner deleted the tstrings-asserthelper branch April 21, 2025 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants