Skip to content

Commit cebcdc5

Browse files
authored
More coverage (#885)
* more coverage * fix test on windows * fix script handling * fix invocation
1 parent a2dd977 commit cebcdc5

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ concurrency:
99
group: ci-${{ github.ref }}
1010
cancel-in-progress: true
1111

12+
defaults:
13+
run:
14+
shell:
15+
bash -eux {0}
16+
17+
1218
jobs:
1319
pre-commit:
1420
runs-on: ubuntu-latest

pyproject.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,14 @@ build = "make -C docs html SPHINXOPTS='-W'"
8888
features = ["test"]
8989
[tool.hatch.envs.test.scripts]
9090
test = "python -m pytest -vv {args}"
91-
nowarn = "python -m pytest -vv -W default {args}"
91+
nowarn = "test -W default {args}"
9292

9393
[tool.hatch.envs.cov]
9494
features = ["test"]
9595
dependencies = ["coverage", "pytest-cov"]
96-
[tool.hatch.envs.cov.env-vars]
97-
ARGS = "-vv --cov jupyter_client --cov-branch --cov-report term-missing:skip-covered"
9896
[tool.hatch.envs.cov.scripts]
99-
test = "python -m pytest $ARGS {args}"
100-
nowarn = "python -m pytest $ARGS -W default {args}"
97+
test = "python -m pytest -vv --cov jupyter_client --cov-branch --cov-report term-missing:skip-covered {args}"
98+
nowarn = "test -W default {args}"
10199

102100
[tool.black]
103101
line-length = 100

tests/test_session.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
# Copyright (c) Jupyter Development Team.
33
# Distributed under the terms of the Modified BSD License.
44
import hmac
5+
import math
56
import os
67
import platform
78
import uuid
9+
import warnings
810
from datetime import datetime
911
from unittest import mock
1012

@@ -518,10 +520,21 @@ def test_json_packer():
518520
with pytest.raises(ValueError):
519521
ss.json_packer(dict(a=ss.Session()))
520522
ss.json_packer(dict(a=datetime(2021, 4, 1, 12, tzinfo=tzlocal())))
523+
with warnings.catch_warnings():
524+
warnings.simplefilter("ignore")
525+
ss.json_packer(dict(a=math.inf))
521526

522527

523528
def test_message_cls():
524529
m = ss.Message(dict(a=1))
525530
foo = dict(m)
526531
assert foo['a'] == 1
527532
assert m['a'] == 1, m['a']
533+
assert 'a' in m
534+
assert str(m) == "{'a': 1}"
535+
536+
537+
def test_session_factory():
538+
s = ss.SessionFactory()
539+
s.log.info(str(s.context))
540+
s.context.destroy()

tests/test_ssh.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
import socket
2+
3+
import pytest
4+
5+
from jupyter_client.ssh.tunnel import open_tunnel
16
from jupyter_client.ssh.tunnel import select_random_ports
27

38

49
def test_random_ports():
5-
for i in range(4096):
10+
for _ in range(4096):
611
ports = select_random_ports(10)
712
assert len(ports) == 10
813
for p in ports:
914
assert ports.count(p) == 1
15+
16+
17+
def test_open_tunnel():
18+
with pytest.raises((RuntimeError, socket.error)):
19+
open_tunnel("tcp://localhost:1234", "does.not.exist")

0 commit comments

Comments
 (0)