Skip to content

Commit 6f92a33

Browse files
authored
Merge #618 test: enable test_connect_socket Windows
2 parents 38cbc4f + e3bad8b commit 6f92a33

File tree

3 files changed

+38
-38
lines changed

3 files changed

+38
-38
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: ci
22
on:
33
push:
4+
branches:
5+
- 'master'
46
pull_request:
57
branches:
68
- 'master'

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,26 @@ Install
1313
Supports python 3.10 or later.
1414

1515
- Installation option #1: install using uv (recommended):
16-
17-
- Install uv (https://docs.astral.sh/uv/).
18-
16+
- Install [uv](https://docs.astral.sh/uv/).
1917
- Install pynvim (the `--upgrade` switch ensures installation of the latest
2018
version):
21-
22-
uv tool install --upgrade pynvim
23-
19+
```
20+
uv tool install --upgrade pynvim
21+
```
2422
- Anytime you upgrade Neovim, make sure to upgrade pynvim as well by
2523
re-running the above command.
26-
2724
- Installation option #2: install using pipx:
28-
2925
- Install pipx (https://pipx.pypa.io/stable/).
30-
3126
- Install pynvim:
32-
33-
pipx install pynvim
34-
27+
```
28+
pipx install pynvim
29+
```
3530
- Anytime you upgrade Neovim, make sure to upgrade pynvim as well by
3631
running:
37-
38-
pipx upgrade pynvim
39-
32+
```
33+
pipx upgrade pynvim
34+
```
4035
- Other installation options:
41-
4236
- See [pynvim installation
4337
documentation](https://pynvim.readthedocs.io/en/latest/installation.html)
4438
for additional installation options and information.
@@ -100,6 +94,12 @@ directory to `sys.path` (otherwise `pytest` might find other versions!):
10094

10195
python -m pytest
10296

97+
Or use [uv](https://docs.astral.sh/uv/) to run tests and linting without managing a virtualenv:
98+
99+
uvx --with pynvim --with pytest --with pytest-timeout pytest
100+
uvx --with pynvim --with flake8-import-order --with flake8-docstrings --with pep8-naming flake8 pynvim test
101+
uvx --with pynvim --with msgpack-types mypy --show-error-codes pynvim test
102+
103103
For details about testing and troubleshooting, see the
104104
[development](http://pynvim.readthedocs.io/en/latest/development.html)
105105
documentation.

test/test_attach.py

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,30 @@
1818
# pylint: disable=redefined-outer-name
1919

2020

21-
xfail_on_windows = pytest.mark.xfail(
22-
"os.name == 'nt'", reason="Broken in Windows, see #544")
21+
@pytest.fixture
22+
def server_addr() -> Generator[str, None, None]:
23+
"""Get a socket/named pipe address using serverstart().
2324
25+
On UNIX this is a socket path, on Windows a named pipe.
26+
"""
27+
nvim = pynvim.attach('child', argv=[
28+
"nvim", "--clean", "--embed",
29+
])
30+
addr = nvim.funcs.serverstart()
31+
nvim.funcs.serverstop(addr)
32+
nvim.close()
2433

25-
@pytest.fixture
26-
def tmp_socket() -> Generator[str, None, None]:
27-
"""Get a temporary UNIX socket file."""
28-
# see cpython#93914
29-
addr = tempfile.mktemp(prefix="test_python_", suffix='.sock',
30-
dir=os.path.curdir)
31-
try:
32-
yield addr
33-
finally:
34-
if os.path.exists(addr):
35-
with contextlib.suppress(OSError):
36-
os.unlink(addr)
34+
yield addr
3735

3836

39-
@xfail_on_windows
40-
def test_connect_socket(tmp_socket: str) -> None:
41-
"""Tests UNIX socket connection."""
42-
p = subprocess.Popen(["nvim", "--clean", "-n", "--headless",
43-
"--listen", tmp_socket])
37+
def test_connect_socket(server_addr: str) -> None:
38+
"""Tests socket/pipe connection."""
39+
p = subprocess.Popen(["nvim", "--clean", "--headless",
40+
"--listen", server_addr])
4441
time.sleep(0.2) # wait a bit until nvim starts up
4542

4643
try:
47-
nvim: Nvim = pynvim.attach('socket', path=tmp_socket)
44+
nvim: Nvim = pynvim.attach('socket', path=server_addr)
4845
assert 42 == nvim.eval('42')
4946
assert "?" == nvim.command_output('echo "?"')
5047
finally:
@@ -69,7 +66,7 @@ def test_connect_tcp() -> None:
6966
"""Tests TCP connection."""
7067
address = '127.0.0.1'
7168
port = find_free_port()
72-
p = subprocess.Popen(["nvim", "--clean", "-n", "--headless",
69+
p = subprocess.Popen(["nvim", "--clean", "--headless",
7370
"--listen", f"{address}:{port}"])
7471
time.sleep(0.2) # wait a bit until nvim starts up
7572

@@ -91,7 +88,8 @@ def test_connect_tcp_no_server() -> None:
9188
pynvim.attach('tcp', address='127.0.0.1', port=port)
9289

9390

94-
@xfail_on_windows
91+
@pytest.mark.xfail("os.name == 'nt'",
92+
reason="stdio attach broken on Windows, see #544")
9593
def test_connect_stdio(vim: Nvim) -> None:
9694
"""Tests stdio connection, using jobstart(..., {'rpc': v:true})."""
9795

0 commit comments

Comments
 (0)