File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 44from .cli import CliTest
55from .config import ConfigTest
66from .core import CoreTest
7+ from .lsp import LspTest
78from .util import UtilTest
Original file line number Diff line number Diff line change 1+ # Copyright Amethyst Reese
2+ # Licensed under the MIT license
3+
4+ from io import StringIO
5+ from pathlib import Path
6+ from tempfile import TemporaryDirectory
7+ from threading import Timer
8+ from unittest import TestCase
9+
10+ from ufmt .lsp import ufmt_lsp
11+
12+
13+ class LspTest (TestCase ):
14+ def setUp (self ) -> None :
15+ self .td = TemporaryDirectory ()
16+ self .tdp = Path (self .td .name ).resolve ()
17+ self .addCleanup (self .td .cleanup )
18+
19+ def test_startup_shutdown (self ) -> None :
20+ stdin = StringIO ()
21+ stdout = StringIO ()
22+
23+ server = ufmt_lsp (root = self .tdp )
24+
25+ def times_up () -> None :
26+ server .shutdown () # type:ignore[no-untyped-call]
27+ raise RuntimeError ("had to forcefully shutdown lsp" )
28+
29+ timer = Timer (5 , times_up )
30+ timer .start ()
31+ server .start_io (stdin , stdout )
32+ timer .cancel ()
You can’t perform that action at this time.
0 commit comments