JetBrains / teamcity-messages

Python Unit Test Reporting to TeamCity
https://pypi.python.org/pypi/teamcity-messages
Apache License 2.0
138 stars 81 forks source link

AttributeError: Values instance has no attribute 'no_teamcity' #190

Closed igelgrun closed 5 years ago

igelgrun commented 6 years ago

In teamcity-messages/teamcity/flake8_v3_plugin.py:

TeamcityReport::add_options (https://github.com/JetBrains/teamcity-messages/blob/4d5d2cd388bfc1d07fa9f2acc21b237ca30e9e09/teamcity/flake8_v3_plugin.py#L17)

Flag options_added belongs to class but parser is comming from parameters. So, sometimes method doesn't add proper options and parse_options raises the following:

/usr/local/lib/python2.7/dist-packages/pluggy/hooks.py:258: in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
/usr/local/lib/python2.7/dist-packages/pluggy/manager.py:67: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
/usr/local/lib/python2.7/dist-packages/pluggy/manager.py:61: in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
/usr/local/lib/python2.7/dist-packages/_pytest/runner.py:111: in pytest_runtest_call
    item.runtest()
/usr/local/lib/python2.7/dist-packages/pytest_flake8.py:117: in runtest
    self.statistics)
/usr/local/lib/python2.7/dist-packages/py/_io/capture.py:150: in call
    res = func(*args, **kwargs)
/usr/local/lib/python2.7/dist-packages/pytest_flake8.py:186: in check_file
    app.parse_configuration_and_cli(args)
/usr/local/lib/python2.7/dist-packages/flake8/main/application.py:224: in parse_configuration_and_cli
    self.args)
/usr/local/lib/python2.7/dist-packages/flake8/plugins/manager.py:449: in provide_options
    list(self.manager.map(call_provide_options))
/usr/local/lib/python2.7/dist-packages/flake8/plugins/manager.py:311: in map
    yield func(self.plugins[name], *args, **kwargs)
/usr/local/lib/python2.7/dist-packages/flake8/plugins/manager.py:411: in generated_function
    return method(optmanager, *args, **kwargs)
/usr/local/lib/python2.7/dist-packages/flake8/plugins/manager.py:212: in provide_options
    parse_options(options)
/usr/local/lib/python2.7/dist-packages/teamcity/flake8_v3_plugin.py:33: in parse_options
    if not options.no_teamcity:
E   AttributeError: Values instance has no attribute 'no_teamcity'
edwelker commented 5 years ago

+1

sambrightman commented 5 years ago

I cannot figure out why options are not added properly. For me, the plugin never works even though debug logging showing all the right calls until flake8.options.manager.OptionManager.add_option. If I raise an exception from this method when it's called with args[0] == '--teamcity', the exception always fires. If the exception is not raised, the method never logs that the option was added at the failure above occurs later.

sambrightman commented 5 years ago

Actually it's clear: the class property is only false once, so the first test passes. An exception prevents this, which allows each subsequent use to try to add the option again. Options need to be added once per instance.