summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2021-11-28 20:19:13 -0500
committerJeff Forcier <jeff@bitprophet.org>2021-11-28 20:24:18 -0500
commitbbdf8040f5c24afd6e26089a3eb7da5f774f8e8b (patch)
tree37fa582933c2a67c4ab7bb4e6fe57758f992e545
parent854583de6554d86a7333956a75dce562acbbc2ee (diff)
downloadparamiko-bbdf8040f5c24afd6e26089a3eb7da5f774f8e8b.tar.gz
Cleanup re #992
- remove apparently vestigial bits - remove Python 2.6 related bits - use pytest.skip instead of custom skip
-rw-r--r--tests/__init__.py37
-rw-r--r--tests/test_sftp.py16
2 files changed, 7 insertions, 46 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
index e767c090..7ded9f18 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -1,45 +1,10 @@
-# Copyright (C) 2017 Martin Packman <gzlist@googlemail.com>
-#
-# This file is part of paramiko.
-#
-# Paramiko is free software; you can redistribute it and/or modify it under the
-# terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; either version 2.1 of the License, or (at your option)
-# any later version.
-#
-# Paramiko is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with Paramiko; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-
"""Base classes and helpers for testing paramiko."""
import functools
import locale
import os
-import unittest
-
-from paramiko.py3compat import (
- builtins,
- )
-
-
-skip = getattr(unittest, "skip", None)
-if skip is None:
- def skip(reason):
- """Stub skip decorator for Python 2.6 compatibility."""
- return lambda func: None
-
-def skipUnlessBuiltin(name):
- """Skip decorated test if builtin name does not exist."""
- if getattr(builtins, name, None) is None:
- return skip("No builtin " + repr(name))
- return lambda func: func
+from pytest import skip
# List of locales which have non-ascii characters in all categories.
diff --git a/tests/test_sftp.py b/tests/test_sftp.py
index 84c5252b..1d6048bb 100644
--- a/tests/test_sftp.py
+++ b/tests/test_sftp.py
@@ -34,11 +34,7 @@ import pytest
from paramiko.py3compat import PY2, b, u, StringIO
from paramiko.common import o777, o600, o666, o644
-from tests import requireNonAsciiLocale, skipUnlessBuiltin
-from tests.stub_sftp import StubServer, StubSFTPServer
-from tests.loop import LoopSocket
-from tests.util import test_path
-import paramiko.util
+from tests import requireNonAsciiLocale
from paramiko.sftp_attr import SFTPAttributes
from .util import needs_builtin
@@ -276,14 +272,14 @@ class TestSFTP(object):
sftp.remove(sftp.FOLDER + "/tertiary.py")
@requireNonAsciiLocale()
- def test_listdir_in_locale(self):
+ def test_listdir_in_locale(self, sftp):
"""Test listdir under a locale that uses non-ascii text."""
- sftp.open(FOLDER + '/canard.txt', 'w').close()
+ sftp.open(sftp.FOLDER + '/canard.txt', 'w').close()
try:
- folder_contents = sftp.listdir(FOLDER)
+ folder_contents = sftp.listdir(sftp.FOLDER)
self.assertEqual(['canard.txt'], folder_contents)
finally:
- sftp.remove(FOLDER + '/canard.txt')
+ sftp.remove(sftp.FOLDER + '/canard.txt')
def test_setstat(self, sftp):
"""
@@ -797,7 +793,7 @@ class TestSFTP(object):
sftp.remove("%s/nonutf8data" % sftp.FOLDER)
@requireNonAsciiLocale('LC_TIME')
- def test_sftp_attributes_locale_time(self):
+ def test_sftp_attributes_locale_time(self, sftp):
"""Test SFTPAttributes under a locale with non-ascii time strings."""
some_stat = os.stat(sftp.FOLDER)
sftp_attributes = SFTPAttributes.from_stat(some_stat, u('a_directory'))