Skip to content

Refactor fixtures #52

@Tobiky

Description

@Tobiky

The fixtures for didOpen and others are found as constants in the test utils folder. Move these into actual pytest fixtures of the didOpen and respective tests. Ideally, the fixtures should be concrete fixture files, however creating an in-memory representation with modifications also works.

To create a pytest fixture that depends on one of the fixture file, see the following example.

@pytest.fixture
def in_memory_file(fixture_file_name: typing.BinaryIO):
     buffer = io.BytesIO(fixture_file_name.readall())
     buffer.write(/* modifications */)
     return buffer

It is important to note that pytest will invoke this function seperately for each test that depends on the fixture and so they will all receive a unique buffer. If multiple tests are using the same value of the test, feel free to change the scope of the fixture (see pytest docs).

Since the fixtures for didOpen also modified the root conftest.py auto-importer of fixture files, this change should also be reverted.

Lastly, change the model DidOpenTextDocumentParams fields to have camel case names.

Reference diffs:

Metadata

Metadata

Assignees

Labels

P-highHigh priorityT-testModification or additions to tests, or new types of tests

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions