From b7df94b8a419f7ed949421d22896286dc1b15233 Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Wed, 25 Oct 2017 11:42:19 -0700 Subject: Mark known slow tests as 'slow' pytest marker, and skip them by default --- tasks.py | 17 +++++++++++++++-- tests/test_auth.py | 3 ++- tests/test_client.py | 3 ++- tests/test_sftp.py | 3 ++- tests/test_sftp_big.py | 3 +++ tests/test_transport.py | 4 +++- tests/util.py | 3 +++ 7 files changed, 30 insertions(+), 6 deletions(-) diff --git a/tasks.py b/tasks.py index 53d99b26..3b34818c 100644 --- a/tasks.py +++ b/tasks.py @@ -9,9 +9,19 @@ from invocations.testing import count_errors @task -def test(ctx, verbose=True, coverage=False, opts=""): +def test(ctx, verbose=True, coverage=False, include_slow=False, opts=""): + """ + Run unit tests via pytest. + + By default, known-slow parts of the suite are SKIPPED unless + ``--include-slow`` is given. (Note that ``--include-slow`` does not mesh + well with explicit ``--opts="-m=xxx"`` - if ``-m`` is found in ``--opts``, + ``--include-slow`` will be ignored!) + """ if verbose and '--verbose' not in opts and '-v' not in opts: opts += " --verbose" + if '-m' not in opts and not include_slow: + opts += " -m 'not slow'" runner = "pytest" if coverage: # Leverage how pytest can be run as 'python -m pytest', and then how @@ -34,7 +44,10 @@ def test(ctx, verbose=True, coverage=False, opts=""): @task def coverage(ctx, opts=""): - return test(ctx, coverage=True, opts=opts) + """ + Execute all tests (normal and slow) with coverage enabled. + """ + return test(ctx, coverage=True, include_slow=True, opts=opts) # Until we stop bundling docs w/ releases. Need to discover use cases first. diff --git a/tests/test_auth.py b/tests/test_auth.py index c619dc33..4eade610 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -33,7 +33,7 @@ from paramiko import AUTH_FAILED, AUTH_PARTIALLY_SUCCESSFUL, AUTH_SUCCESSFUL from paramiko.py3compat import u from .loop import LoopSocket -from .util import _support +from .util import _support, slow _pwd = u('\u2022') @@ -240,6 +240,7 @@ class AuthTest (unittest.TestCase): etype, evalue, etb = sys.exc_info() self.assertTrue(issubclass(etype, AuthenticationException)) + @slow def test_9_auth_non_responsive(self): """ verify that authentication times out if server takes to long to diff --git a/tests/test_client.py b/tests/test_client.py index fd662604..0483cf6f 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -38,7 +38,7 @@ from paramiko.pkey import PublicBlob from paramiko.common import PY2 from paramiko.ssh_exception import SSHException, AuthenticationException -from .util import _support +from .util import _support, slow requires_gss_auth = unittest.skipUnless( @@ -443,6 +443,7 @@ class SSHClientTest (unittest.TestCase): ) self._test_connection(**kwargs) + @slow def test_9_auth_timeout(self): """ verify that the SSHClient has a configurable auth timeout diff --git a/tests/test_sftp.py b/tests/test_sftp.py index 57b5bc97..09a50453 100644 --- a/tests/test_sftp.py +++ b/tests/test_sftp.py @@ -42,7 +42,7 @@ from paramiko.sftp_attr import SFTPAttributes from .util import needs_builtin from .stub_sftp import StubServer, StubSFTPServer -from .util import _support +from .util import _support, slow ARTICLE = ''' @@ -88,6 +88,7 @@ unicode_folder = u'\u00fcnic\u00f8de' if PY2 else '\u00fcnic\u00f8de' utf8_folder = b'/\xc3\xbcnic\xc3\xb8\x64\x65' +@slow class TestSFTP(object): def test_1_file(self, sftp): """ diff --git a/tests/test_sftp_big.py b/tests/test_sftp_big.py index e5708312..a659098d 100644 --- a/tests/test_sftp_big.py +++ b/tests/test_sftp_big.py @@ -32,7 +32,10 @@ import unittest from paramiko.common import o660 +from .util import slow + +@slow class TestBigSFTP(object): def test_1_lots_of_files(self, sftp): """ diff --git a/tests/test_transport.py b/tests/test_transport.py index 46c26c0e..00639d04 100644 --- a/tests/test_transport.py +++ b/tests/test_transport.py @@ -44,7 +44,7 @@ from paramiko.common import ( from paramiko.py3compat import bytes from paramiko.message import Message -from .util import needs_builtin, _support +from .util import needs_builtin, _support, slow from .loop import LoopSocket @@ -246,6 +246,7 @@ class TransportTest(unittest.TestCase): self.tc.renegotiate_keys() self.ts.send_ignore(1024) + @slow def test_5_keepalive(self): """ verify that the keepalive will be sent. @@ -809,6 +810,7 @@ class TransportTest(unittest.TestCase): (2**32, MAX_WINDOW_SIZE)]: self.assertEqual(self.tc._sanitize_window_size(val), correct) + @slow def test_L_handshake_timeout(self): """ verify that we can get a hanshake timeout. diff --git a/tests/util.py b/tests/util.py index 051a36ba..4ca02374 100644 --- a/tests/util.py +++ b/tests/util.py @@ -22,3 +22,6 @@ def needs_builtin(name): """ reason = "Test requires a builtin '{}'".format(name) return pytest.mark.skipif(not hasattr(builtins, name), reason=reason) + + +slow = pytest.mark.slow -- cgit v1.2.3