diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -340,10 +340,7 @@ def terminate(proc): """Terminate subprocess (with fallback for Python versions < 2.6)""" vlog('# Terminating process %d' % proc.pid) try: - if hasattr(proc, 'terminate'): - proc.terminate() - else: - os.kill(proc.pid, signal.SIGTERM) + getattr(proc, 'terminate', lambda : os.kill(proc.pid, signal.SIGTERM))() except OSError: pass diff --git a/tests/sitecustomize.py b/tests/sitecustomize.py --- a/tests/sitecustomize.py +++ b/tests/sitecustomize.py @@ -1,6 +1,5 @@ try: import coverage - if hasattr(coverage, 'process_startup'): - coverage.process_startup() + getattr(coverage, 'process_startup', lambda: None)() except ImportError: pass diff --git a/tests/test-symlink-os-yes-fs-no.py b/tests/test-symlink-os-yes-fs-no.py --- a/tests/test-symlink-os-yes-fs-no.py +++ b/tests/test-symlink-os-yes-fs-no.py @@ -5,7 +5,7 @@ TESTDIR = os.environ["TESTDIR"] BUNDLEPATH = os.path.join(TESTDIR, 'bundles', 'test-no-symlinks.hg') # only makes sense to test on os which supports symlinks -if not hasattr(os, "symlink"): +if not getattr(os, "symlink", False): sys.exit(80) # SKIPPED_STATUS defined in run-tests.py # clone with symlink support diff --git a/tests/test-walkrepo.py b/tests/test-walkrepo.py --- a/tests/test-walkrepo.py +++ b/tests/test-walkrepo.py @@ -5,7 +5,7 @@ from os import mkdir, chdir from os.path import join as pjoin u = ui.ui() -sym = hasattr(os, 'symlink') and hasattr(os.path, 'samestat') +sym = getattr(os, 'symlink', False) and getattr(os.path, 'samestat', False) hg.repository(u, 'top1', create=1) mkdir('subdir') diff --git a/tests/tinyproxy.py b/tests/tinyproxy.py --- a/tests/tinyproxy.py +++ b/tests/tinyproxy.py @@ -23,7 +23,8 @@ class ProxyHandler (BaseHTTPServer.BaseH def handle(self): (ip, port) = self.client_address - if hasattr(self, 'allowed_clients') and ip not in self.allowed_clients: + allowed = getattr(self, 'allowed_clients', None) + if allowed is not None and ip not in allowed: self.raw_requestline = self.rfile.readline() if self.parse_request(): self.send_error(403)