summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2023-05-04 17:58:23 -0400
committerJeff Forcier <jeff@bitprophet.org>2023-05-05 12:27:20 -0400
commit5465e2d8fb50b97f8e1fa682c82c81613196cc0c (patch)
tree3968bd8beadb58edf624a141b51db7b44f05cce3
parentc29274a9424b1e7ac9f3f1f5e2d714b7d47e7979 (diff)
downloadparamiko-5465e2d8fb50b97f8e1fa682c82c81613196cc0c.tar.gz
Move auth tests to be new style filename, obj naming
Also allow test task module selector to see new-style test modules
-rw-r--r--tasks.py7
-rw-r--r--tests/auth.py (renamed from tests/test_auth.py)20
2 files changed, 15 insertions, 12 deletions
diff --git a/tasks.py b/tasks.py
index 1f5e999c..f58f699e 100644
--- a/tasks.py
+++ b/tasks.py
@@ -1,4 +1,5 @@
import os
+from pathlib import Path
from os.path import join
from shutil import rmtree, copytree
@@ -50,8 +51,10 @@ def test(
opts += " -f"
modstr = ""
if module is not None:
- # NOTE: implicit test_ prefix as we're not on pytest-relaxed yet
- modstr = " tests/test_{}.py".format(module)
+ base = f"{module}.py"
+ tests = Path("tests")
+ legacy = tests / f"test_{base}"
+ modstr = str(legacy if legacy.exists() else tests / base)
# Switch runner depending on coverage or no coverage.
# TODO: get pytest's coverage plugin working, IIRC it has issues?
runner = "pytest"
diff --git a/tests/test_auth.py b/tests/auth.py
index 70ee0c36..08de6148 100644
--- a/tests/test_auth.py
+++ b/tests/auth.py
@@ -32,8 +32,8 @@ from paramiko import (
from ._util import _support, server, unicodey
-class AuthTest(unittest.TestCase):
- def test_bad_auth_type(self):
+class AuthHandler_:
+ def bad_auth_type(self):
"""
verify that we get the right exception when an unsupported auth
type is requested.
@@ -47,7 +47,7 @@ class AuthTest(unittest.TestCase):
assert isinstance(err, BadAuthenticationType)
assert err.allowed_types == ["publickey"]
- def test_bad_password(self):
+ def bad_password(self):
"""
verify that a bad password gets the right exception, and that a retry
with the right password works.
@@ -61,7 +61,7 @@ class AuthTest(unittest.TestCase):
# And again, correctly
tc.auth_password(username="slowdive", password="pygmalion")
- def test_multipart_auth(self):
+ def multipart_auth(self):
"""
verify that multipart auth works.
"""
@@ -72,7 +72,7 @@ class AuthTest(unittest.TestCase):
key = DSSKey.from_private_key_file(_support("dss.key"))
assert tc.auth_publickey(username="paranoid", key=key) == []
- def test_interactive_auth(self):
+ def interactive_auth(self):
"""
verify keyboard-interactive auth works.
"""
@@ -88,7 +88,7 @@ class AuthTest(unittest.TestCase):
assert self.got_title == "password"
assert self.got_prompts == [("Password", False)]
- def test_interactive_auth_fallback(self):
+ def interactive_fallback(self):
"""
verify that a password auth attempt will fallback to "interactive"
if password auth isn't supported but interactive is.
@@ -98,14 +98,14 @@ class AuthTest(unittest.TestCase):
# and has a configured interactive->response on the server.
assert tc.auth_password("commie", "cat") == []
- def test_auth_utf8(self):
+ def utf8(self):
"""
verify that utf-8 encoding happens in authentication.
"""
with server(defer=True) as (tc, ts):
assert tc.auth_password("utf8", unicodey) == []
- def test_auth_non_utf8(self):
+ def non_utf8(self):
"""
verify that non-utf-8 encoded passwords can be used for broken
servers.
@@ -113,7 +113,7 @@ class AuthTest(unittest.TestCase):
with server(defer=True) as (tc, ts):
assert tc.auth_password("non-utf8", "\xff") == []
- def test_auth_gets_disconnected(self):
+ def auth_exception_when_disconnected(self):
"""
verify that we catch a server disconnecting during auth, and report
it as an auth failure.
@@ -123,7 +123,7 @@ class AuthTest(unittest.TestCase):
):
tc.auth_password("bad-server", "hello")
- def test_auth_non_responsive(self):
+ def non_responsive_triggers_auth_exception(self):
"""
verify that authentication times out if server takes to long to
respond (or never responds).