• 
      

    Fix using the @requires_user_profile decorator with unit test classes.

    Review Request #10987 — Created April 3, 2020 and submitted

    Information

    Djblets
    release-1.0.x

    Reviewers

    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, using setattr() instead.

    Verified that the unit tests that weren't running before do run now.

    Summary ID
    Fix using the @requires_user_profile decorator with unit test classes.
    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, using `setattr()` instead.
    4f6ef23a0e7e3df672e42216d02bae5c4d839e44
    david
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-1.0.x (2f5ed41)