diff --git a/.coveragerc b/.coveragerc index 12432738..407348f4 100644 --- a/.coveragerc +++ b/.coveragerc @@ -9,5 +9,6 @@ exclude_lines = partial_branches = pragma: no branch for .* -omit = - .tox/* +include = + asyncssh/* + tests/* diff --git a/asyncssh/config.py b/asyncssh/config.py index 24cbcbde..e3f37d39 100644 --- a/asyncssh/config.py +++ b/asyncssh/config.py @@ -477,7 +477,7 @@ def _set_tokens(self) -> None: conn_hash = sha1(conn_info.encode('utf-8')).hexdigest() self._tokens.update({'C': conn_hash, - 'd': str(Path.home()), + 'd': str(os.path.expanduser('~')), 'h': host, 'L': short_local_host, 'l': local_host, diff --git a/tests/test_config.py b/tests/test_config.py index f5da9227..d96a4281 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -357,13 +357,13 @@ def mock_gethostname(): return 'thishost.local' - def mock_home(): + def mock_expanduser(_): """Return a static local home directory""" return '/home/user' with patch('socket.gethostname', mock_gethostname): - with patch('pathlib.Path.home', mock_home): + with patch('os.path.expanduser', mock_expanduser): config = self._parse_config( 'Hostname newhost\n' 'User newuser\n' diff --git a/tests/test_public_key.py b/tests/test_public_key.py index 228f3f89..b7d82cc9 100644 --- a/tests/test_public_key.py +++ b/tests/test_public_key.py @@ -71,6 +71,11 @@ _openssl_available = _openssl_version != b'' +if _openssl_available: + _openssl_curves = run('openssl ecparam -list_curves') +else: + _openssl_curves = b'' + # The openssl "-v2prf" option is only available in OpenSSL 1.0.2 or later _openssl_supports_v2prf = _openssl_version >= b'OpenSSL 1.0.2' @@ -2260,9 +2265,9 @@ def test_ec_explicit(self): '-param_enc explicit' % curve) asyncssh.read_private_key('priv') - @unittest.skipIf(b'secp224r1' not in run('openssl ecparam -list_curves'), - "this openssl doesn't support secp224r1") @unittest.skipIf(not _openssl_available, "openssl isn't available") + @unittest.skipIf(b'secp224r1' not in _openssl_curves, + "this openssl doesn't support secp224r1") def test_ec_explicit_unknown(self): """Import EC key with unknown explicit parameters""" diff --git a/tox.ini b/tox.ini index 53492fab..4e6b380a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,23 +1,48 @@ [tox] -envlist = {py36,py37,py38,py39,py310}-{linux,macos,windows} +minversion = 3.7 +envlist = clean,{py36,py37,py38,py39,py310}-{linux,darwin,windows},report +skip_missing_interpreters = True [testenv] deps = + aiofiles>=0.6.0 bcrypt>=3.1.3 - coverage - linux,macos: gssapi>=1.2.0 + fido2>=0.9.2 libnacl>=1.4.2 pyOpenSSL>=17.0.0 - python-pkcs11>=0.7.0 + pytest>=7.0.1 + pytest-cov>=3.0.0 setuptools>=18.5 + linux,darwin: gssapi>=1.2.0 + linux,darwin: python-pkcs11>=0.7.0 + linux,darwin: uvloop>=0.9.1 windows: pywin32>=227 - {py36,py37,py38,py39,py310}-{linux,macos}: uvloop>=0.9.1 platform = linux: linux - macos: darwin + darwin: darwin windows: win32 -sitepackages = True -skip_missing_interpreters = True usedevelop = True +setenv = + {py36,py37,py38,py39,py310}-{linux,darwin,windows}: COVERAGE_FILE = .coverage.{envname} +commands = + {envpython} -m pytest --cov --cov-report=term-missing:skip-covered {posargs} +depends = + {py36,py37,py38,py39,py310}-{linux,darwin,windows}: clean + report: {py36,py37,py38,py39,py310}-{linux,darwin,windows} + +[testenv:clean] +deps = coverage +skip_install = true +commands = coverage erase + +[testenv:report] +deps = coverage +skip_install = true +parallel_show_output = true commands = - {envpython} -m coverage run -p -m unittest + coverage combine + coverage report --show-missing + coverage html + +[pytest] +testpaths = tests