Skip to content
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

Check categories are mixed up after subsequent runs #3533

Closed
julen opened this issue Dec 5, 2016 · 0 comments
Closed

Check categories are mixed up after subsequent runs #3533

julen opened this issue Dec 5, 2016 · 0 comments

Comments

@julen
Copy link
Contributor

julen commented Dec 5, 2016

The check categories are assigned to the class upon respective method execution via the decorators. This is problematic if some code wants to read the categories for a specific checker after another checker has run, because the class attribute is shared across instances.

This breaks code/tests in Pootle, e.g. get_qualitychecks.

The weird behavior can be demonstrated with this test, which is expected to fail:

def test_category():
    """Tests checker categories aren't mixed up."""
    from translate.storage import base
    unit = base.TranslationUnit(u'foo')
    unit.target = u'bar'

    standard_checker = checks.StandardChecker()
    assert standard_checker.categories == {}
    standard_checker.run_filters(unit)
    assert standard_checker.categories != {}
    assert 'validxml' not in standard_checker.categories.keys()
    standard_categories_count = len(standard_checker.categories.values())

    libo_checker = checks.LibreOfficeChecker()
    assert libo_checker.categories == {}
    libo_checker.run_filters(unit)
    assert libo_checker.categories != {}
    assert 'validxml' in libo_checker.categories.keys()

    standard_checker = checks.StandardChecker()
    assert standard_checker.categories == {}
    standard_checker.run_filters(unit)
    assert standard_checker.categories != {}
    assert len(standard_checker.categories.values()) == standard_categories_count
    assert 'validxml' not in standard_checker.categories.keys()

Leaving aside possible improvements to how tests are categorized and executed, a less surprising behavior would be to store the categories on instances. I will PR a patch in this direction.

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

No branches or pull requests

1 participant