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

Fix test_syntax_error_pylint_py3 for Python 3.10 #133

Merged
merged 1 commit into from
Dec 6, 2021
Merged

Fix test_syntax_error_pylint_py3 for Python 3.10 #133

merged 1 commit into from
Dec 6, 2021

Conversation

ArchangeGabriel
Copy link
Contributor

The PR at #112 was supposed to fix this test, but actually it still does not work for me on python 3.10:

_________________________ test_syntax_error_pylint_py3 _________________________

config = <pylsp.config.config.Config object at 0x7faa011ea590>
workspace = <pylsp.workspace.Workspace object at 0x7faa01185360>

    @py3_only
    def test_syntax_error_pylint_py3(config, workspace):
        with temp_document(DOC_SYNTAX_ERR, workspace) as doc:
            diag = pylint_lint.pylsp_lint(config, doc, True)[0]
    
            if sys.version_info[:2] >= (3, 10):
                assert diag['message'].count("[syntax-error] expected ':'")
            else:
                assert diag['message'].startswith('[syntax-error] invalid syntax')
            # Pylint doesn't give column numbers for invalid syntax.
            assert diag['range']['start'] == {'line': 0, 'character': 12}
            assert diag['severity'] == lsp.DiagnosticSeverity.Error
    
            # test running pylint in stdin
            config.plugin_settings('pylint')['executable'] = 'pylint'
            diag = pylint_lint.pylsp_lint(config, doc, True)[0]
    
>           assert diag['message'].startswith('invalid syntax')
E           assert False
E            +  where False = <built-in method startswith of str object at 0x7fa9fbb18ff0>('invalid syntax')
E            +    where <built-in method startswith of str object at 0x7fa9fbb18ff0> = "expected ':' (<unknown>, line 1) (syntax-error)".startswith

test/plugins/test_pylint_lint.py:87: AssertionError
---------------------------- Captured stderr setup -----------------------------
2021-12-05 15:04:53,587 UTC - DEBUG - pylsp.config.config -   pylsp_settings [hook]
      config: <pylsp.config.config.Config object at 0x7faa01184f10>

2021-12-05 15:04:53,587 UTC - DEBUG - pylsp.config.config -   finish pylsp_settings --> [] [hook]

2021-12-05 15:04:53,587 UTC - INFO - pylsp.config.config - Disabled plugins: []
2021-12-05 15:04:53,593 UTC - DEBUG - pylsp.config.config -   pylsp_settings [hook]
      config: <pylsp.config.config.Config object at 0x7faa011ea590>

2021-12-05 15:04:53,593 UTC - DEBUG - pylsp.config.config -   finish pylsp_settings --> [] [hook]

2021-12-05 15:04:53,593 UTC - INFO - pylsp.config.config - Disabled plugins: []
------------------------------ Captured log setup ------------------------------
DEBUG    pylsp.config.config:_tracing.py:34   pylsp_settings [hook]
      config: <pylsp.config.config.Config object at 0x7faa01184f10>

DEBUG    pylsp.config.config:_tracing.py:34   finish pylsp_settings --> [] [hook]

INFO     pylsp.config.config:config.py:156 Disabled plugins: []
DEBUG    pylsp.config.config:_tracing.py:34   pylsp_settings [hook]
      config: <pylsp.config.config.Config object at 0x7faa011ea590>

DEBUG    pylsp.config.config:_tracing.py:34   finish pylsp_settings --> [] [hook]

INFO     pylsp.config.config:config.py:156 Disabled plugins: []
----------------------------- Captured stderr call -----------------------------
2021-12-05 15:04:53,594 UTC - DEBUG - pylsp.config.config - Got user config from PyCodeStyleConfig: {}
2021-12-05 15:04:53,595 UTC - DEBUG - pylsp.config.config - Got project config from PyCodeStyleConfig: {}
2021-12-05 15:04:53,595 UTC - DEBUG - pylsp.config.config - With configuration: {'plugins': {'pylint': {'enabled': False, 'args': [], 'executable': None}}}
2021-12-05 15:04:53,595 UTC - DEBUG - pylsp.plugins.pylint_lint - Got pylint settings: {'enabled': False, 'args': [], 'executable': None}
2021-12-05 15:04:53,595 UTC - DEBUG - pylsp.plugins.pylint_lint - Calling pylint with '/tmp/tmp_su622bf -f json '
2021-12-05 15:04:54,125 UTC - DEBUG - pylsp.plugins.pylint_lint - Got pylint settings: {'enabled': False, 'args': [], 'executable': 'pylint'}
2021-12-05 15:04:54,125 UTC - DEBUG - pylsp.plugins.pylint_lint - Calling pylint with args: '[]'
2021-12-05 15:04:54,647 UTC - DEBUG - pylsp.plugins.pylint_lint - Pylint output parser can't parse line '************* Module tmp_su622bf'
------------------------------ Captured log call -------------------------------
DEBUG    pylsp.config.config:config.py:120 Got user config from PyCodeStyleConfig: {}
DEBUG    pylsp.config.config:config.py:129 Got project config from PyCodeStyleConfig: {}
DEBUG    pylsp.config.config:config.py:132 With configuration: {'plugins': {'pylint': {'enabled': False, 'args': [], 'executable': None}}}
DEBUG    pylsp.plugins.pylint_lint:pylint_lint.py:174 Got pylint settings: {'enabled': False, 'args': [], 'executable': None}
DEBUG    pylsp.plugins.pylint_lint:pylint_lint.py:72 Calling pylint with '/tmp/tmp_su622bf -f json '
DEBUG    pylsp.plugins.pylint_lint:pylint_lint.py:174 Got pylint settings: {'enabled': False, 'args': [], 'executable': 'pylint'}
DEBUG    pylsp.plugins.pylint_lint:pylint_lint.py:234 Calling pylint with args: '[]'
DEBUG    pylsp.plugins.pylint_lint:pylint_lint.py:268 Pylint output parser can't parse line '************* Module tmp_su622bf'

Looking at the previous change and the reported error, I’ve figured out this should be the proper fix.

Only the first assert was modified in 2e06283.
@ccordoba12 ccordoba12 added this to the v1.3.3 milestone Dec 6, 2021
Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the help @ArchangeGabriel!

@ccordoba12 ccordoba12 merged commit 3096e6c into python-lsp:develop Dec 6, 2021
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

Successfully merging this pull request may close these issues.

2 participants