diff options
| author | Giampaolo Rodola <g.rodola@gmail.com> | 2017-05-10 20:38:05 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-05-10 20:38:05 +0200 |
| commit | 58aef46d74ff577f60eb9e0478d6de3361c8a4e9 (patch) | |
| tree | fea3e3cf33de981dd1d54d12cb7f718876d3b244 | |
| parent | 596b43381711248093caf1c1df3b5d93d0c70bb6 (diff) | |
| download | psutil-58aef46d74ff577f60eb9e0478d6de3361c8a4e9.tar.gz | |
1058 enable fix warnings (#1059)
* #1058: have Makefile use PYTHONWARNINGS=all by default for (almost) all commands
* #1058 fix linux tests warnings
* #1058: try not to use imp module
* #1058: get rid of imp module completely
* #1058: ignore unicode warnings
* #1058: ignore stderr from procsmem.py
* #1058: fix resource warning from Popen
* #1058: get rid of contextlib.nested (deprecated)
| -rw-r--r-- | HISTORY.rst | 2 | ||||
| -rw-r--r-- | Makefile | 56 | ||||
| -rw-r--r-- | psutil/_compat.py | 50 | ||||
| -rw-r--r-- | psutil/tests/__init__.py | 60 | ||||
| -rwxr-xr-x | psutil/tests/test_connections.py | 11 | ||||
| -rwxr-xr-x | psutil/tests/test_linux.py | 24 | ||||
| -rwxr-xr-x | psutil/tests/test_misc.py | 15 | ||||
| -rwxr-xr-x | psutil/tests/test_posix.py | 3 | ||||
| -rwxr-xr-x | psutil/tests/test_process.py | 4 | ||||
| -rwxr-xr-x | psutil/tests/test_unicode.py | 10 | ||||
| -rwxr-xr-x | setup.py | 11 |
11 files changed, 129 insertions, 117 deletions
diff --git a/HISTORY.rst b/HISTORY.rst index bc909608..3e5f0f47 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -19,6 +19,7 @@ comprehensions. - 1040_: implemented full unicode support. - 1051_: disk_usage() on Python 3 is now able to accept bytes. +- 1058_: test suite now enables all warnings by default. **Bug fixes** @@ -41,6 +42,7 @@ - 1046_: [Windows] disk_partitions() on Windows overrides user's SetErrorMode. - 1047_: [Windows] Process username(): memory leak in case exception is thrown. - 1048_: [Windows] users()'s host field report an invalid IP address. +- 1058_: fixed Python warnings. **Porting notes** @@ -63,11 +63,11 @@ _: # Compile without installing. build: _ - $(PYTHON) setup.py build + PYTHONWARNINGS=all $(PYTHON) setup.py build @# copies compiled *.so files in ./psutil directory in order to allow @# "import psutil" when using the interactive interpreter from within @# this directory. - $(PYTHON) setup.py build_ext -i + PYTHONWARNINGS=all $(PYTHON) setup.py build_ext -i rm -rf tmp # Install this package + GIT hooks. Install is done: @@ -77,7 +77,7 @@ install: ${MAKE} build # make sure setuptools is installed (needed for 'develop' / edit mode) $(PYTHON) -c "import setuptools" - $(PYTHON) setup.py develop $(INSTALL_OPTS) + PYTHONWARNINGS=all $(PYTHON) setup.py develop $(INSTALL_OPTS) rm -rf tmp # Uninstall this package via pip. @@ -86,7 +86,7 @@ uninstall: # Install PIP (only if necessary). install-pip: - $(PYTHON) -c \ + PYTHONWARNINGS=all $(PYTHON) -c \ "import sys, ssl, os, pkgutil, tempfile, atexit; \ sys.exit(0) if pkgutil.find_loader('pip') else None; \ pyexc = 'from urllib.request import urlopen' if sys.version_info[0] == 3 else 'from urllib2 import urlopen'; \ @@ -118,65 +118,65 @@ setup-dev-env: # Run all tests. test: ${MAKE} install - $(PYTHON) $(TSCRIPT) + PYTHONWARNINGS=all $(PYTHON) $(TSCRIPT) # Run process-related API tests. test-process: ${MAKE} install - $(PYTHON) -m unittest -v psutil.tests.test_process + PYTHONWARNINGS=all $(PYTHON) -m unittest -v psutil.tests.test_process # Run system-related API tests. test-system: ${MAKE} install - $(PYTHON) -m unittest -v psutil.tests.test_system + PYTHONWARNINGS=all $(PYTHON) -m unittest -v psutil.tests.test_system # Run miscellaneous tests. test-misc: ${MAKE} install - $(PYTHON) psutil/tests/test_misc.py + PYTHONWARNINGS=all $(PYTHON) psutil/tests/test_misc.py # Test APIs dealing with strings. test-unicode: ${MAKE} install - $(PYTHON) psutil/tests/test_unicode.py + PYTHONWARNINGS=all $(PYTHON) psutil/tests/test_unicode.py # APIs sanity tests. test-contracts: ${MAKE} install - $(PYTHON) psutil/tests/test_contracts.py + PYTHONWARNINGS=all $(PYTHON) psutil/tests/test_contracts.py # Test net_connections() and Process.connections(). test-connections: ${MAKE} install - $(PYTHON) psutil/tests/test_connections.py + PYTHONWARNINGS=all $(PYTHON) psutil/tests/test_connections.py # POSIX specific tests. test-posix: ${MAKE} install - $(PYTHON) psutil/tests/test_posix.py + PYTHONWARNINGS=all $(PYTHON) psutil/tests/test_posix.py # Run specific platform tests only. test-platform: ${MAKE} install - $(PYTHON) psutil/tests/test_`$(PYTHON) -c 'import psutil; print([x.lower() for x in ("LINUX", "BSD", "OSX", "SUNOS", "WINDOWS") if getattr(psutil, x)][0])'`.py + PYTHONWARNINGS=all $(PYTHON) psutil/tests/test_`$(PYTHON) -c 'import psutil; print([x.lower() for x in ("LINUX", "BSD", "OSX", "SUNOS", "WINDOWS") if getattr(psutil, x)][0])'`.py # Memory leak tests. test-memleaks: ${MAKE} install - $(PYTHON) psutil/tests/test_memory_leaks.py + PYTHONWARNINGS=all $(PYTHON) psutil/tests/test_memory_leaks.py # Run a specific test by name, e.g. # make test-by-name psutil.tests.test_system.TestSystemAPIs.test_cpu_times test-by-name: ${MAKE} install - @$(PYTHON) -m unittest -v $(ARGS) + @PYTHONWARNINGS=all $(PYTHON) -m unittest -v $(ARGS) # Run test coverage. coverage: ${MAKE} install # Note: coverage options are controlled by .coveragerc file rm -rf .coverage htmlcov - $(PYTHON) -m coverage run $(TSCRIPT) + PYTHONWARNINGS=all $(PYTHON) -m coverage run $(TSCRIPT) $(PYTHON) -m coverage report @echo "writing results to htmlcov/index.html" $(PYTHON) -m coverage html @@ -197,7 +197,7 @@ flake8: @git ls-files | grep \\.py$ | xargs $(PYTHON) -m flake8 check-manifest: - $(PYTHON) -m check_manifest -v $(ARGS) + PYTHONWARNINGS=all $(PYTHON) -m check_manifest -v $(ARGS) # =================================================================== # GIT @@ -220,22 +220,22 @@ install-git-hooks: # Upload source tarball on https://pypi.python.org/pypi/psutil. upload-src: ${MAKE} clean - $(PYTHON) setup.py sdist upload + PYTHONWARNINGS=all $(PYTHON) setup.py sdist upload # Download exes/wheels hosted on appveyor. win-download-exes: - $(PYTHON) scripts/internal/download_exes.py --user giampaolo --project psutil + PYTHONWARNINGS=all $(PYTHON) scripts/internal/download_exes.py --user giampaolo --project psutil # Upload exes/wheels in dist/* directory to PYPI. win-upload-exes: - $(PYTHON) -m twine upload dist/*.exe - $(PYTHON) -m twine upload dist/*.whl + PYTHONWARNINGS=all $(PYTHON) -m twine upload dist/*.exe + PYTHONWARNINGS=all $(PYTHON) -m twine upload dist/*.whl # All the necessary steps before making a release. pre-release: ${MAKE} clean ${MAKE} install # to import psutil from download_exes.py - $(PYTHON) -c \ + PYTHONWARNINGS=all $(PYTHON) -c \ "from psutil import __version__ as ver; \ doc = open('docs/index.rst').read(); \ history = open('HISTORY.rst').read(); \ @@ -244,18 +244,18 @@ pre-release: assert 'XXXX' not in history; \ " ${MAKE} win-download-exes - $(PYTHON) setup.py sdist + PYTHONWARNINGS=all $(PYTHON) setup.py sdist # Create a release: creates tar.gz and exes/wheels, uploads them, # upload doc, git tag release. release: ${MAKE} pre-release - $(PYTHON) -m twine upload dist/* # upload tar.gz, exes, wheels on PYPI + PYTHONWARNINGS=all $(PYTHON) -m twine upload dist/* # upload tar.gz, exes, wheels on PYPI ${MAKE} git-tag-release # Print announce of new release. print-announce: - @$(PYTHON) scripts/internal/print_announce.py + @PYTHONWARNINGS=all $(PYTHON) scripts/internal/print_announce.py # =================================================================== # Misc @@ -267,12 +267,12 @@ grep-todos: # run script which benchmarks oneshot() ctx manager (see #799) bench-oneshot: ${MAKE} install - $(PYTHON) scripts/internal/bench_oneshot.py + PYTHONWARNINGS=all $(PYTHON) scripts/internal/bench_oneshot.py # same as above but using perf module (supposed to be more precise) bench-oneshot-2: ${MAKE} install - $(PYTHON) scripts/internal/bench_oneshot_2.py + PYTHONWARNINGS=all $(PYTHON) scripts/internal/bench_oneshot_2.py # generate a doc.zip file and manually upload it to PYPI. doc: @@ -282,4 +282,4 @@ doc: # check whether the links mentioned in some files are valid. check-broken-links: - git ls-files | grep \\.rst$ | xargs $(PYTHON) scripts/internal/check_broken_links.py + git ls-files | grep \\.rst$ | xargs PYTHONWARNINGS=all $(PYTHON) scripts/internal/check_broken_links.py diff --git a/psutil/_compat.py b/psutil/_compat.py index a318f70f..de91638f 100644 --- a/psutil/_compat.py +++ b/psutil/_compat.py @@ -5,13 +5,12 @@ """Module which provides compatibility with older Python versions.""" import collections -import contextlib import functools import os import sys __all__ = ["PY3", "long", "xrange", "unicode", "basestring", "u", "b", - "callable", "lru_cache", "which", "nested"] + "callable", "lru_cache", "which"] PY3 = sys.version_info[0] == 3 @@ -248,50 +247,3 @@ except ImportError: if _access_check(name, mode): return name return None - - -# A backport of contextlib.nested for Python 3. -nested = getattr(contextlib, "nested", None) -if nested is None: - @contextlib.contextmanager - def nested(*managers): - """Support multiple context managers in a single with-statement. - - Code like this: - - with nested(A, B, C) as (X, Y, Z): - <body> - - is equivalent to this: - - with A as X: - with B as Y: - with C as Z: - <body> - """ - exits = [] - vars = [] - exc = (None, None, None) - try: - for mgr in managers: - exit = mgr.__exit__ - enter = mgr.__enter__ - vars.append(enter()) - exits.append(exit) - yield vars - except: # NOQA - exc = sys.exc_info() - finally: - while exits: - exit = exits.pop() - try: - if exit(*exc): - exc = (None, None, None) - except: # NOQA - exc = sys.exc_info() - if exc != (None, None, None): - # Don't rely on sys.exc_info() still containing - # the right information. Another exception may - # have been raised and caught by an exit method - # exc[1] already has the __traceback__ attribute populated - raise exc[1] diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py index a77b5f5d..03ad9553 100644 --- a/psutil/tests/__init__.py +++ b/psutil/tests/__init__.py @@ -58,14 +58,6 @@ if sys.version_info >= (3, 4): else: enum = None -if PY3: - import importlib - # python <=3.3 - if not hasattr(importlib, 'reload'): - import imp as importlib -else: - import imp as importlib - __all__ = [ # constants @@ -98,16 +90,13 @@ __all__ = [ 'check_connection_ntuple', 'check_net_address', 'get_free_port', 'unix_socket_path', 'bind_socket', 'bind_unix_socket', 'tcp_socketpair', 'unix_socketpair', 'create_sockets', + # compat + 'reload_module', 'import_module_by_path', # others 'warn', 'copyload_shared_lib', 'is_namedtuple', ] -# Enable all warnings by default. -if 'PYTHONWARNINGS' not in os.environ: - warnings.simplefilter('always') - - # =================================================================== # --- constants # =================================================================== @@ -353,16 +342,19 @@ def pyrun(src, **kwds): @_cleanup_on_err -def sh(cmd): +def sh(cmd, **kwds): """run cmd in a subprocess and return its output. raises RuntimeError on error. """ shell = True if isinstance(cmd, (str, unicode)) else False # Prevents subprocess to open error dialogs in case of error. flags = 0x8000000 if WINDOWS and shell else 0 - p = subprocess.Popen(cmd, shell=shell, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, universal_newlines=True, - creationflags=flags) + kwds.setdefault("shell", shell) + kwds.setdefault("stdout", subprocess.PIPE) + kwds.setdefault("stderr", subprocess.PIPE) + kwds.setdefault("universal_newlines", True) + kwds.setdefault("creationflags", flags) + p = subprocess.Popen(cmd, **kwds) stdout, stderr = p.communicate() if p.returncode != 0: raise RuntimeError(stderr) @@ -976,6 +968,40 @@ def check_connection_ntuple(conn): # =================================================================== +# --- compatibility +# =================================================================== + + +def reload_module(module): + """Backport of importlib.reload of Python 3.3+.""" + try: + import importlib + if not hasattr(importlib, 'reload'): # python <=3.3 + raise ImportError + except ImportError: + import imp + return imp.reload(module) + else: + return importlib.reload(module) + + +def import_module_by_path(path): + name = os.path.splitext(os.path.basename(path))[0] + if sys.version_info[0] == 2: + import imp + return imp.load_source(name, path) + elif sys.version_info[:2] <= (3, 4): + from importlib.machinery import SourceFileLoader + return SourceFileLoader(name, path).load_module() + else: + import importlib.util + spec = importlib.util.spec_from_file_location(name, path) + mod = importlib.util.module_from_spec(spec) + spec.loader.exec_module(mod) + return mod + + +# =================================================================== # --- others # =================================================================== diff --git a/psutil/tests/test_connections.py b/psutil/tests/test_connections.py index d0c5445a..906706a5 100755 --- a/psutil/tests/test_connections.py +++ b/psutil/tests/test_connections.py @@ -26,7 +26,6 @@ from psutil import SUNOS from psutil import WINDOWS from psutil._common import pconn from psutil._common import supports_ipv6 -from psutil._compat import nested from psutil._compat import PY3 from psutil.tests import AF_UNIX from psutil.tests import bind_socket @@ -207,7 +206,7 @@ class TestConnectedSocketPairs(Base, unittest.TestCase): addr = ("127.0.0.1", get_free_port()) assert not thisproc.connections(kind='tcp4') server, client = tcp_socketpair(AF_INET, addr=addr) - with nested(closing(server), closing(client)): + try: cons = thisproc.connections(kind='tcp4') self.assertEqual(len(cons), 2) self.assertEqual(cons[0].status, psutil.CONN_ESTABLISHED) @@ -218,12 +217,15 @@ class TestConnectedSocketPairs(Base, unittest.TestCase): # cons = thisproc.connections(kind='all') # self.assertEqual(len(cons), 1) # self.assertEqual(cons[0].status, psutil.CONN_CLOSE_WAIT) + finally: + server.close() + client.close() @unittest.skipIf(not POSIX, 'POSIX only') def test_unix(self): with unix_socket_path() as name: server, client = unix_socketpair(name) - with nested(closing(server), closing(client)): + try: cons = thisproc.connections(kind='unix') assert not (cons[0].laddr and cons[0].raddr) assert not (cons[1].laddr and cons[1].raddr) @@ -248,6 +250,9 @@ class TestConnectedSocketPairs(Base, unittest.TestCase): # of both peers are set. self.assertEqual(cons[0].laddr or cons[1].laddr, name) self.assertEqual(cons[0].raddr or cons[1].raddr, name) + finally: + server.close() + client.close() @skip_on_access_denied(only_if=OSX) def test_combos(self): diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py index 4adcb376..2054da8b 100755 --- a/psutil/tests/test_linux.py +++ b/psutil/tests/test_linux.py @@ -30,12 +30,12 @@ from psutil._compat import u from psutil.tests import call_until from psutil.tests import HAS_BATTERY from psutil.tests import HAS_RLIMIT -from psutil.tests import importlib from psutil.tests import MEMORY_TOLERANCE from psutil.tests import mock from psutil.tests import PYPY from psutil.tests import pyrun from psutil.tests import reap_children +from psutil.tests import reload_module from psutil.tests import retry_before_failing from psutil.tests import run_test_module_by_name from psutil.tests import safe_rmpath @@ -324,9 +324,13 @@ class TestSystemVirtualMemory(unittest.TestCase): orig_open = open patch_point = 'builtins.open' if PY3 else '__builtin__.open' with mock.patch(patch_point, create=True, side_effect=open_mock) as m: - ret = psutil.virtual_memory() + with warnings.catch_warnings(record=True) as ws: + ret = psutil.virtual_memory() assert m.called self.assertEqual(ret.available, 6574984 * 1024) + w = ws[0] + self.assertIn( + "inactive memory stats couldn't be determined", str(w.message)) def test_avail_old_missing_fields(self): # Remove Active(file), Inactive(file) and SReclaimable @@ -351,9 +355,13 @@ class TestSystemVirtualMemory(unittest.TestCase): orig_open = open patch_point = 'builtins.open' if PY3 else '__builtin__.open' with mock.patch(patch_point, create=True, side_effect=open_mock) as m: - ret = psutil.virtual_memory() + with warnings.catch_warnings(record=True) as ws: + ret = psutil.virtual_memory() assert m.called self.assertEqual(ret.available, 2057400 * 1024 + 4818144 * 1024) + w = ws[0] + self.assertIn( + "inactive memory stats couldn't be determined", str(w.message)) def test_avail_old_missing_zoneinfo(self): # Remove /proc/zoneinfo file. Make sure fallback is used @@ -382,9 +390,13 @@ class TestSystemVirtualMemory(unittest.TestCase): orig_open = open patch_point = 'builtins.open' if PY3 else '__builtin__.open' with mock.patch(patch_point, create=True, side_effect=open_mock) as m: - ret = psutil.virtual_memory() + with warnings.catch_warnings(record=True) as ws: + ret = psutil.virtual_memory() assert m.called self.assertEqual(ret.available, 2057400 * 1024 + 4818144 * 1024) + w = ws[0] + self.assertIn( + "inactive memory stats couldn't be determined", str(w.message)) # ===================================================================== @@ -986,7 +998,7 @@ class TestMisc(unittest.TestCase): patch_point = 'builtins.open' if PY3 else '__builtin__.open' with mock.patch(patch_point, side_effect=open_mock): - importlib.reload(psutil) + reload_module(psutil) assert tb.called self.assertRaises(IOError, psutil.cpu_times) @@ -1025,7 +1037,7 @@ class TestMisc(unittest.TestCase): sum(map(sum, psutil.cpu_times_percent(percpu=True))), 0) finally: shutil.rmtree(my_procfs) - importlib.reload(psutil) + reload_module(psutil) self.assertEqual(psutil.PROCFS_PATH, '/proc') diff --git a/psutil/tests/test_misc.py b/psutil/tests/test_misc.py index 28c40ed7..0e1ce350 100755 --- a/psutil/tests/test_misc.py +++ b/psutil/tests/test_misc.py @@ -13,7 +13,6 @@ import ast import collections import contextlib import errno -import imp import json import os import pickle @@ -36,6 +35,7 @@ from psutil.tests import call_until from psutil.tests import chdir from psutil.tests import create_proc_children_pair from psutil.tests import create_sockets +from psutil.tests import DEVNULL from psutil.tests import get_free_port from psutil.tests import get_test_subprocess from psutil.tests import HAS_BATTERY @@ -44,10 +44,11 @@ from psutil.tests import HAS_MEMORY_MAPS from psutil.tests import HAS_SENSORS_BATTERY from psutil.tests import HAS_SENSORS_FANS from psutil.tests import HAS_SENSORS_TEMPERATURES -from psutil.tests import importlib +from psutil.tests import import_module_by_path from psutil.tests import is_namedtuple from psutil.tests import mock from psutil.tests import reap_children +from psutil.tests import reload_module from psutil.tests import retry from psutil.tests import ROOT_DIR from psutil.tests import run_test_module_by_name @@ -352,7 +353,7 @@ class TestMisc(unittest.TestCase): def test_setup_script(self): setup_py = os.path.join(ROOT_DIR, 'setup.py') - module = imp.load_source('setup', setup_py) + module = import_module_by_path(setup_py) self.assertRaises(SystemExit, module.setup) self.assertEqual(module.get_version(), psutil.__version__) @@ -378,7 +379,7 @@ class TestMisc(unittest.TestCase): with mock.patch( "psutil._psplatform.cext.version", return_value="0.0.0"): with self.assertRaises(ImportError) as cm: - importlib.reload(psutil) + reload_module(psutil) self.assertIn("version conflict", str(cm.exception).lower()) @@ -631,12 +632,12 @@ class TestScripts(unittest.TestCase): """Tests for scripts in the "scripts" directory.""" @staticmethod - def assert_stdout(exe, args=None): + def assert_stdout(exe, args=None, **kwds): exe = '"%s"' % os.path.join(SCRIPTS_DIR, exe) if args: exe = exe + ' ' + args try: - out = sh(sys.executable + ' ' + exe).strip() + out = sh(sys.executable + ' ' + exe, **kwds).strip() except RuntimeError as err: if 'AccessDenied' in str(err): return str(err) @@ -712,7 +713,7 @@ class TestScripts(unittest.TestCase): @unittest.skipIf(not HAS_MEMORY_FULL_INFO, "not supported") def test_procsmem(self): - self.assert_stdout('procsmem.py') + self.assert_stdout('procsmem.py', stderr=DEVNULL) def test_killall(self): self.assert_syntax('killall.py') diff --git a/psutil/tests/test_posix.py b/psutil/tests/test_posix.py index 3274c02c..d3d2d5b1 100755 --- a/psutil/tests/test_posix.py +++ b/psutil/tests/test_posix.py @@ -224,7 +224,8 @@ class TestProcess(unittest.TestCase): p = psutil.Process(os.getpid()) failures = [] ignored_names = ['terminate', 'kill', 'suspend', 'resume', 'nice', - 'send_signal', 'wait', 'children', 'as_dict'] + 'send_signal', 'wait', 'children', 'as_dict', + 'memory_info_ex'] if LINUX and get_kernel_version() < (2, 6, 36): ignored_names.append('rlimit') if LINUX and get_kernel_version() < (2, 6, 23): diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py index 598180c9..86ad136f 100755 --- a/psutil/tests/test_process.py +++ b/psutil/tests/test_process.py @@ -1397,7 +1397,9 @@ class TestProcess(unittest.TestCase): self.assertTrue(dir(proc)) self.assertRaises(AttributeError, getattr, proc, 'foo') finally: - proc.kill() + proc.terminate() + proc.stdout.close() + proc.stderr.close() proc.wait() def test_Popen_ctx_manager(self): diff --git a/psutil/tests/test_unicode.py b/psutil/tests/test_unicode.py index ae3c012f..159ccdff 100755 --- a/psutil/tests/test_unicode.py +++ b/psutil/tests/test_unicode.py @@ -53,6 +53,7 @@ For a detailed explanation of how psutil handles unicode see: """ import os +import warnings from contextlib import closing from psutil import BSD @@ -61,6 +62,7 @@ from psutil import OSX from psutil import POSIX from psutil import WINDOWS from psutil._compat import PY3 +from psutil._compat import u from psutil.tests import ASCII_FS from psutil.tests import bind_unix_socket from psutil.tests import chdir @@ -264,7 +266,13 @@ class TestFSAPIs(_BaseFSAPIsTests, unittest.TestCase): def expect_exact_path_match(cls): # Do not expect psutil to correctly handle unicode paths on # Python 2 if os.listdir() is not able either. - return PY3 or cls.funky_name in os.listdir('.') + if PY3: + return True + else: + here = '.' if isinstance(cls.funky_name, str) else u('.') + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + return cls.funky_name in os.listdir(here) @unittest.skipIf(OSX and TRAVIS, "unreliable on TRAVIS") # TODO @@ -16,10 +16,13 @@ import platform import sys import tempfile import warnings -try: - from setuptools import setup, Extension -except ImportError: - from distutils.core import setup, Extension + +with warnings.catch_warnings(): + warnings.simplefilter("ignore") + try: + from setuptools import setup, Extension + except ImportError: + from distutils.core import setup, Extension HERE = os.path.abspath(os.path.dirname(__file__)) |
