microsoft / microsoft/multilspy

Test conflicts with preinstalled `black` on the system

Open
#94 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
610
Forks
111
PR merge metrics
No merged PRs in 30d

Description

Not sure what's the exact cause but running with black installed on the system makes test fail.

py -m pytest -p no:pytest-blender tests\multilspy\test_multilspy_python.py --capture=no
# tests\multilspy\test_multilspy_python.py::test_multilspy_python_black PASSED
pip install black
py -m pytest -p no:pytest-blender tests\multilspy\test_multilspy_python.py --capture=no
# tests\multilspy\test_multilspy_python.py::test_multilspy_python_black FAILED

Full error:

tests\multilspy\test_multilspy_python.py::test_multilspy_python_black FAILED

================================================================================= FAILURES =================================================================================
_______________________________________________________________________ test_multilspy_python_black ________________________________________________________________________

    @pytest.mark.asyncio
    async def test_multilspy_python_black():
        """
        Test the working of multilspy with python repository - black
        """
        code_language = Language.PYTHON
        params = {
            "code_language": code_language,
            "repo_url": "https://github.com/psf/black/",
            "repo_commit": "f3b50e466969f9142393ec32a4b2a383ffbe5f23"
        }
        with create_test_context(params) as context:
            lsp = LanguageServer.create(context.config, context.logger, context.source_directory)
            assert isinstance(lsp, JediServer)

            # All the communication with the language server must be performed inside the context manager
            # The server process is started when the context manager is entered and is terminated when the context manager is exited.
            # The context manager is an asynchronous context manager, so it must be used with async with.
            async with lsp.start_server():
                result = await lsp.request_definition(str(PurePath("src/black/mode.py")), 163, 4)

                assert isinstance(result, list)
                assert len(result) == 1
                item = result[0]
                assert item["relativePath"] == str(PurePath("src/black/mode.py"))
                assert item["range"] == {
                    "start": {"line": 163, "character": 4},
                    "end": {"line": 163, "character": 20},
                }
                result = await lsp.request_references(str(PurePath("src/black/mode.py")), 163, 4)

                assert isinstance(result, list)
>               assert len(result) == 8
E               AssertionError: assert 1 == 8
E                +  where 1 = len([{'absolutePath': '.multilspy\\451905597f9045e08699f99b582e63f0\\black-f3b50e466969f9142393ec32a4b2a383ffbe5f23\\src\\black\\mode.py', 'range': {'end': {'character': 20, 'line': 163}, 'start': {'character': 4, 'line': 163}}, 'relativePath': 'src\\black\\mode.py', 'uri': 'file:///c:/.multilspy/451905597f9045e08699f99b582e63f0/black-f3b50e466969f9142393ec32a4b2a383ffbe5f23/src/black/mode.py'}])

tests\multilspy\test_multilspy_python.py:46: AssertionError
---------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------
INFO     multilspy:multilspy_logger.py:56 {"time": "2025-03-29 11:21:21", "level": "INFO", "caller_file": "multilspy\\tests\\..\\src\\multilspy\\language_servers\\jedi_language_server\\jedi_server.py", "caller_name": "start_server", "caller_line": 99, "message": "Starting jedi-language-server server process"}
INFO     multilspy:multilspy_logger.py:56 {"time": "2025-03-29 11:21:21", "level": "INFO", "caller_file": "multilspy\\tests\\..\\src\\multilspy\\language_servers\\jedi_language_server\\jedi_server.py", "caller_name": "start_server", "caller_line": 103, "message": "Sending initialize request from LSP client to LSP server and awaiting response"}
========================================================================= short test summary info ==========================================================================
FAILED tests\multilspy\test_multilspy_python.py::test_multilspy_python_black - AssertionError: assert 1 == 8

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the two commands from the issue and compare test_multilspy_python_black in tests/multilspy/test_multilspy_python.py before and after installing black. Trace the test's Python language-server setup and dependency environment; done means the test passes consistently whether black is preinstalled or not.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.