• 
      

    Fix no-ops with the @online_only unit test decorator.

    Review Request #14940 — Created March 18, 2026 and submitted

    Information

    Review Board
    release-7.1.x

    Reviewers

    In 2021, the @online_only decorator was rewritten to use
    @simple_decorator, but the result was a function that performed no-ops
    when online. Instead of calling the test function with the provided
    arguments, it just returned the first argument as-is (which was the
    self argument to the unit test class). This got ignored, resulting in
    nothing happening when the test was run.

    This did unveil that one test (Mercurial's HTTPS tests) were no longer
    passing. This was due to the repository having bot protection deployed,
    which meant we were getting HTTP 200 results that weren't actually the
    file contents. We've switched to Mozilla's HG server for our test, which
    currently has no bot protection.

    Unit tests pass.

    Summary ID
    Fix no-ops with the @online_only unit test decorator.
    In 2021, the `@online_only` decorator was rewritten to use `@simple_decorator`, but the result was a function that performed no-ops when online. Instead of calling the test function with the provided arguments, it just returned the first argument as-is (which was the `self` argument to the unit test class). This got ignored, resulting in nothing happening when the test was run. This did unveil that one test (Mercurial's HTTPS tests) were no longer passing. This was due to the repository having bot protection deployed, which meant we were getting HTTP 200 results that weren't actually the file contents. We've switched to Mozilla's HG server for our test, which currently has no bot protection.
    54a4efab49603787b2a46fabd42bb07bf5dfb35f
    Description From Last Updated

    It seems like this should just be return test_func

    david david
    david
    1. 
        
    2. reviewboard/testing/__init__.py (Diff revision 1)
       
       
      Show all issues

      It seems like this should just be return test_func

      1. They're different function types. The decorator needs to return a plain function, and we need to call a bound method. Otherwise you get:

        INTERNALERROR>   File "/Users/chipx86/buildroots/rb7/lib/python3.12/site-packages/_pytest/compat.py", line 244, in get_real_func
        INTERNALERROR>     raise ValueError(
        INTERNALERROR> ValueError: could not find real function of <bound method MercurialTests.test_https_repo of <reviewboard.scmtools.tests.test_hg.MercurialTests testMethod=test_https_repo>>
        INTERNALERROR> stopped at <function MercurialTests.test_https_repo at 0x124376340>
        
    3. 
        
    david
    1. Ship It!
    2. 
        
    maubin
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-7.1.x (87827fb)