Skip to content

Commit 324dddb

Browse files
authored
Merge pull request #451 from hexchain/pytest
Use pytest and friends in tox and a couple of other fixes
2 parents 2f733d5 + c8eaa06 commit 324dddb

File tree

5 files changed

+47
-16
lines changed

5 files changed

+47
-16
lines changed

.coveragerc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ exclude_lines =
99
partial_branches =
1010
pragma: no branch
1111
for .*
12-
omit =
13-
.tox/*
12+
include =
13+
asyncssh/*
14+
tests/*

asyncssh/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ def _set_tokens(self) -> None:
477477
conn_hash = sha1(conn_info.encode('utf-8')).hexdigest()
478478

479479
self._tokens.update({'C': conn_hash,
480-
'd': str(Path.home()),
480+
'd': str(os.path.expanduser('~')),
481481
'h': host,
482482
'L': short_local_host,
483483
'l': local_host,

tests/test_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,13 @@ def mock_gethostname():
357357

358358
return 'thishost.local'
359359

360-
def mock_home():
360+
def mock_expanduser(_):
361361
"""Return a static local home directory"""
362362

363363
return '/home/user'
364364

365365
with patch('socket.gethostname', mock_gethostname):
366-
with patch('pathlib.Path.home', mock_home):
366+
with patch('os.path.expanduser', mock_expanduser):
367367
config = self._parse_config(
368368
'Hostname newhost\n'
369369
'User newuser\n'

tests/test_public_key.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@
7171

7272
_openssl_available = _openssl_version != b''
7373

74+
if _openssl_available:
75+
_openssl_curves = run('openssl ecparam -list_curves')
76+
else:
77+
_openssl_curves = b''
78+
7479
# The openssl "-v2prf" option is only available in OpenSSL 1.0.2 or later
7580
_openssl_supports_v2prf = _openssl_version >= b'OpenSSL 1.0.2'
7681

@@ -2260,9 +2265,9 @@ def test_ec_explicit(self):
22602265
'-param_enc explicit' % curve)
22612266
asyncssh.read_private_key('priv')
22622267

2263-
@unittest.skipIf(b'secp224r1' not in run('openssl ecparam -list_curves'),
2264-
"this openssl doesn't support secp224r1")
22652268
@unittest.skipIf(not _openssl_available, "openssl isn't available")
2269+
@unittest.skipIf(b'secp224r1' not in _openssl_curves,
2270+
"this openssl doesn't support secp224r1")
22662271
def test_ec_explicit_unknown(self):
22672272
"""Import EC key with unknown explicit parameters"""
22682273

tox.ini

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,48 @@
11
[tox]
2-
envlist = {py36,py37,py38,py39,py310}-{linux,macos,windows}
2+
minversion = 3.7
3+
envlist = clean,{py36,py37,py38,py39,py310}-{linux,darwin,windows},report
4+
skip_missing_interpreters = True
35

46
[testenv]
57
deps =
8+
aiofiles>=0.6.0
69
bcrypt>=3.1.3
7-
coverage
8-
linux,macos: gssapi>=1.2.0
10+
fido2>=0.9.2
911
libnacl>=1.4.2
1012
pyOpenSSL>=17.0.0
11-
python-pkcs11>=0.7.0
13+
pytest>=7.0.1
14+
pytest-cov>=3.0.0
1215
setuptools>=18.5
16+
linux,darwin: gssapi>=1.2.0
17+
linux,darwin: python-pkcs11>=0.7.0
18+
linux,darwin: uvloop>=0.9.1
1319
windows: pywin32>=227
14-
{py36,py37,py38,py39,py310}-{linux,macos}: uvloop>=0.9.1
1520
platform =
1621
linux: linux
17-
macos: darwin
22+
darwin: darwin
1823
windows: win32
19-
sitepackages = True
20-
skip_missing_interpreters = True
2124
usedevelop = True
25+
setenv =
26+
{py36,py37,py38,py39,py310}-{linux,darwin,windows}: COVERAGE_FILE = .coverage.{envname}
27+
commands =
28+
{envpython} -m pytest --cov --cov-report=term-missing:skip-covered {posargs}
29+
depends =
30+
{py36,py37,py38,py39,py310}-{linux,darwin,windows}: clean
31+
report: {py36,py37,py38,py39,py310}-{linux,darwin,windows}
32+
33+
[testenv:clean]
34+
deps = coverage
35+
skip_install = true
36+
commands = coverage erase
37+
38+
[testenv:report]
39+
deps = coverage
40+
skip_install = true
41+
parallel_show_output = true
2242
commands =
23-
{envpython} -m coverage run -p -m unittest
43+
coverage combine
44+
coverage report --show-missing
45+
coverage html
46+
47+
[pytest]
48+
testpaths = tests

0 commit comments

Comments
 (0)