# HG changeset patch # User Augie Fackler # Date 1311629838 18000 # Node ID 0b21ae0a23662d08a5b78220b62fc3acaac52c26 # Parent 592e45b7d43e04aa2c1d0bbca3ad2189a2968c3a tests: use getattr instead of hasattr diff -r 592e45b7d43e -r 0b21ae0a2366 tests/run-tests.py --- a/tests/run-tests.py Mon Jul 25 16:05:01 2011 -0500 +++ b/tests/run-tests.py Mon Jul 25 16:37:18 2011 -0500 @@ -340,10 +340,7 @@ """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 -r 592e45b7d43e -r 0b21ae0a2366 tests/sitecustomize.py --- a/tests/sitecustomize.py Mon Jul 25 16:05:01 2011 -0500 +++ b/tests/sitecustomize.py Mon Jul 25 16:37:18 2011 -0500 @@ -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 -r 592e45b7d43e -r 0b21ae0a2366 tests/test-symlink-os-yes-fs-no.py --- a/tests/test-symlink-os-yes-fs-no.py Mon Jul 25 16:05:01 2011 -0500 +++ b/tests/test-symlink-os-yes-fs-no.py Mon Jul 25 16:37:18 2011 -0500 @@ -5,7 +5,7 @@ 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 -r 592e45b7d43e -r 0b21ae0a2366 tests/test-walkrepo.py --- a/tests/test-walkrepo.py Mon Jul 25 16:05:01 2011 -0500 +++ b/tests/test-walkrepo.py Mon Jul 25 16:37:18 2011 -0500 @@ -5,7 +5,7 @@ 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 -r 592e45b7d43e -r 0b21ae0a2366 tests/tinyproxy.py --- a/tests/tinyproxy.py Mon Jul 25 16:05:01 2011 -0500 +++ b/tests/tinyproxy.py Mon Jul 25 16:37:18 2011 -0500 @@ -23,7 +23,8 @@ 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)