-
-
Notifications
You must be signed in to change notification settings - Fork 665
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
Simplify asserts on translations #4359
Conversation
|
|
fee17fa
to
a1033c0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvement.
I tried to make LSP somehow search for these keys on auto-completion so that you would get hints while writing tests but I had no success.
Tried:
- using
__setattr__
in__init__
- overriding
__dir__
The older approach didn't provide any auto-completion support neither though.
we'd probably have to generate a file that has all the available arguments, similar to |
4c6b5c6
to
eb6ed9b
Compare
we need to propagate stacklevel so that the warning is emitted at the usage line instead of deep in translations.py i mean we don't _need_ need to it's just nicer
0bee780
to
2ede124
Compare
this changes UI tests because in edge cases the carousel goes the other (shorter) way
2ede124
to
8b4423e
Compare
with this change, instead of having to use a cumbersome custom
assert_in
assert_in_multiple
etc. and mucking around with multiple possible translationsyou instead use the normal assert capabilities, and say things like
assert TR.some__translation_key in debug.text_content()
, which any Python reader can decipher.also pytest will point you directly to the failing assertion instead of showing you a problem in the function "assert_equals"
before:
after:
as a bonus, you're actually checking against the currently selected language, which caught a small bug in a couple tests, where language was not re-set after a wipe
TR.regexp("translation__key").match(...)
TR.translate(key)
(or, you know,getattr(TR, key)
, but the former is preferable)assert_in_multiple
is now significantly wordier, because the operation "in multiple" does not exist in Python. personally I prefer this for clarity, but if it's a big problem we could re-introduce a helper for this situation?