File: conftest.py

package info (click to toggle)
python-lsp-isort 0.2.2%2Breally%2B0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 84 kB
  • sloc: python: 289; makefile: 5
file content (42 lines) | stat: -rw-r--r-- 1,027 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import shutil
from pathlib import Path
from unittest.mock import Mock

import pytest
from pylsp import uris
from pylsp.config.config import Config
from pylsp.workspace import Document, Workspace

here = Path(__file__).parent
fixtures_dir = here / "fixtures"


@pytest.fixture
def config(workspace):
    return Config(workspace.root_uri, {}, 0, {})


@pytest.fixture
def workspace(tmpdir):
    """Return a workspace."""
    ws = Workspace(uris.from_fs_path(str(tmpdir)), Mock())
    ws._config = Config(ws.root_uri, {}, 0, {})
    return ws


@pytest.fixture
def unformatted_document(workspace):
    return create_document(workspace, "unformatted.py")


@pytest.fixture
def formatted_document(workspace):
    return create_document(workspace, "formatted.py")


def create_document(workspace, name):
    template_path = fixtures_dir / name
    dest_path = Path(workspace.root_path) / name
    shutil.copy(template_path, dest_path)
    document_uri = uris.from_fs_path(str(dest_path))
    return Document(document_uri, workspace)