Fix using the @requires_user_profile decorator with unit test classes.
Review Request #10987 — Created April 3, 2020 and submitted — Latest diff uploaded
The
@requires_user_profile
decorator was added back when modern avatar
support was added, and one of its capabilities was to decorate a class
in order to decorate all test methods within.This didn't actually work. Any class using this decorator would fail to
have its tests run. This was due to the initial check to determine if
this was decorating a function or a class by checking the result of
callable(...)
. Since unit test classes are callable, this passed. It
would then break running the test suite, which would cause the test
runner to ignore the class entirely.We now check if it's a class directly instead, invoking the
class-specific logic for the first time. That logic unfortunately didn't
work, as it was trying to modify an immutable dictionary. This change
also fixes that, usingsetattr()
instead.
Verified that the unit tests that weren't running before do run now.