diff options
| author | ?ric Araujo <merwok@netwok.org> | 2011-02-10 00:51:42 +0100 |
|---|---|---|
| committer | ?ric Araujo <merwok@netwok.org> | 2011-02-10 00:51:42 +0100 |
| commit | 37d72aef1b216abd0840afd73c114bad25621a39 (patch) | |
| tree | f6e479ad1ee4292eccd68aa9b7f120315a143457 | |
| parent | b1bd0f37c556fd24b8cb45cf9d8989a61224144f (diff) | |
| download | disutils2-37d72aef1b216abd0840afd73c114bad25621a39.tar.gz | |
Use lazy form in logging calls, again.
Logging calls have the signature (msg, *args, **kwargs) so that the
%-formatting can be delayed until it is needed. Logger objects also have an
isEnabledFor method that can be used to isolate expensive code.
Next steps: use only one of d2.logger methods or logging module functions;
use a proper handler in our test machinery instead of monkey-patching; remove
cmd.warn and cmd.announce and use logging instead. TODOs have been added in
the modules and on the wiki.
| -rw-r--r-- | distutils2/command/bdist_dumb.py | 13 | ||||
| -rw-r--r-- | distutils2/command/bdist_wininst.py | 2 | ||||
| -rw-r--r-- | distutils2/command/clean.py | 4 | ||||
| -rw-r--r-- | distutils2/command/cmd.py | 4 | ||||
| -rw-r--r-- | distutils2/command/config.py | 2 | ||||
| -rw-r--r-- | distutils2/command/install_dist.py | 2 | ||||
| -rw-r--r-- | distutils2/command/register.py | 10 | ||||
| -rw-r--r-- | distutils2/command/sdist.py | 12 | ||||
| -rw-r--r-- | distutils2/compiler/msvc9compiler.py | 4 | ||||
| -rw-r--r-- | distutils2/config.py | 9 | ||||
| -rw-r--r-- | distutils2/dist.py | 24 | ||||
| -rw-r--r-- | distutils2/index/simple.py | 7 | ||||
| -rw-r--r-- | distutils2/index/xmlrpc.py | 2 | ||||
| -rw-r--r-- | distutils2/install.py | 24 | ||||
| -rw-r--r-- | distutils2/manifest.py | 54 | ||||
| -rw-r--r-- | distutils2/tests/support.py | 3 | ||||
| -rw-r--r-- | distutils2/tests/test_command_build_py.py | 2 | ||||
| -rw-r--r-- | distutils2/tests/test_command_install_lib.py | 2 | ||||
| -rw-r--r-- | distutils2/tests/test_command_sdist.py | 8 | ||||
| -rw-r--r-- | distutils2/tests/test_manifest.py | 9 |
20 files changed, 99 insertions, 98 deletions
diff --git a/distutils2/command/bdist_dumb.py b/distutils2/command/bdist_dumb.py index 8aed45c..419b80c 100644 --- a/distutils2/command/bdist_dumb.py +++ b/distutils2/command/bdist_dumb.py @@ -87,7 +87,7 @@ class bdist_dumb (Command): install.skip_build = self.skip_build install.warn_dir = 0 - logger.info("installing to %s" % self.bdist_dir) + logger.info("installing to %s", self.bdist_dir) self.run_command('install_dist') # And make an archive relative to the root of the @@ -106,11 +106,10 @@ class bdist_dumb (Command): else: if (self.distribution.has_ext_modules() and (install.install_base != install.install_platbase)): - raise DistutilsPlatformError, \ - ("can't make a dumb built distribution where " - "base and platbase are different (%s, %s)" - % (repr(install.install_base), - repr(install.install_platbase))) + raise DistutilsPlatformError( + "can't make a dumb built distribution where base and " + "platbase are different (%r, %r)" % + (install.install_base, install.install_platbase)) else: archive_root = os.path.join( self.bdist_dir, @@ -129,7 +128,7 @@ class bdist_dumb (Command): if not self.keep_temp: if self.dry_run: - logger.info('Removing %s' % self.bdist_dir) + logger.info('Removing %s', self.bdist_dir) else: rmtree(self.bdist_dir) diff --git a/distutils2/command/bdist_wininst.py b/distutils2/command/bdist_wininst.py index 40f151f..ecea86b 100644 --- a/distutils2/command/bdist_wininst.py +++ b/distutils2/command/bdist_wininst.py @@ -192,7 +192,7 @@ class bdist_wininst (Command): if not self.keep_temp: if self.dry_run: - logger.info('Removing %s' % self.bdist_dir) + logger.info('Removing %s', self.bdist_dir) else: rmtree(self.bdist_dir) diff --git a/distutils2/command/clean.py b/distutils2/command/clean.py index 295cfac..97ea367 100644 --- a/distutils2/command/clean.py +++ b/distutils2/command/clean.py @@ -48,7 +48,7 @@ class clean(Command): # gone) if os.path.exists(self.build_temp): if self.dry_run: - logger.info('Removing %s' % self.build_temp) + logger.info('Removing %s', self.build_temp) else: rmtree(self.build_temp) else: @@ -62,7 +62,7 @@ class clean(Command): self.build_scripts): if os.path.exists(directory): if self.dry_run: - logger.info('Removing %s' % directory) + logger.info('Removing %s', directory) else: rmtree(directory) else: diff --git a/distutils2/command/cmd.py b/distutils2/command/cmd.py index 0e4d99e..e91d924 100644 --- a/distutils2/command/cmd.py +++ b/distutils2/command/cmd.py @@ -182,6 +182,7 @@ class Command(object): raise RuntimeError( "abstract method -- subclass %s must override" % self.__class__) + # TODO remove this method, just use logging def announce(self, msg, level=logging.INFO): """If the current verbosity level is of greater than or equal to 'level' print 'msg' to stdout. @@ -363,8 +364,9 @@ class Command(object): # -- External world manipulation ----------------------------------- + # TODO remove this method, just use logging def warn(self, msg): - logger.warning("warning: %s: %s\n" % (self.get_command_name(), msg)) + logger.warning("warning: %s: %s\n", self.get_command_name(), msg) def execute(self, func, args, msg=None, level=1): util.execute(func, args, msg, dry_run=self.dry_run) diff --git a/distutils2/command/config.py b/distutils2/command/config.py index 0f4ae9f..411ad26 100644 --- a/distutils2/command/config.py +++ b/distutils2/command/config.py @@ -345,7 +345,7 @@ def dump_file(filename, head=None): If head is not None, will be dumped before the file content. """ if head is None: - logger.info('%s' % filename) + logger.info(filename) else: logger.info(head) file = open(filename) diff --git a/distutils2/command/install_dist.py b/distutils2/command/install_dist.py index 146c905..247a10e 100644 --- a/distutils2/command/install_dist.py +++ b/distutils2/command/install_dist.py @@ -418,7 +418,7 @@ class install_dist(Command): else: opt_name = opt_name.replace('-', '_') val = getattr(self, opt_name) - logger.debug(" %s: %s" % (opt_name, val)) + logger.debug(" %s: %s", opt_name, val) def select_scheme(self, name): """Set the install directories by applying the install schemes.""" diff --git a/distutils2/command/register.py b/distutils2/command/register.py index 74f708c..3d5bc23 100644 --- a/distutils2/command/register.py +++ b/distutils2/command/register.py @@ -92,7 +92,7 @@ class register(Command): ''' # send the info to the server and report the result code, result = self.post_to_server(self.build_post_data('verify')) - logger.info('Server response (%s): %s' % (code, result)) + logger.info('Server response (%s): %s', code, result) def send_metadata(self): @@ -206,18 +206,18 @@ Your selection [default 1]: ''', logging.INFO) data['email'] = raw_input(' EMail: ') code, result = self.post_to_server(data) if code != 200: - logger.info('Server response (%s): %s' % (code, result)) + logger.info('Server response (%s): %s', code, result) else: logger.info('You will receive an email shortly.') - logger.info(('Follow the instructions in it to ' - 'complete registration.')) + logger.info('Follow the instructions in it to ' + 'complete registration.') elif choice == '3': data = {':action': 'password_reset'} data['email'] = '' while not data['email']: data['email'] = raw_input('Your email address: ') code, result = self.post_to_server(data) - logger.info('Server response (%s): %s' % (code, result)) + logger.info('Server response (%s): %s', (code, result)) def build_post_data(self, action): # figure the data to send - the metadata plus some additional diff --git a/distutils2/command/sdist.py b/distutils2/command/sdist.py index 5aff9bd..3c78f81 100644 --- a/distutils2/command/sdist.py +++ b/distutils2/command/sdist.py @@ -2,10 +2,7 @@ Implements the Distutils 'sdist' command (create a source distribution).""" import os -import string import sys -from glob import glob -from warnings import warn from shutil import rmtree import re from StringIO import StringIO @@ -18,11 +15,10 @@ except ImportError: from distutils2.command import get_command_names from distutils2.command.cmd import Command from distutils2.errors import (DistutilsPlatformError, DistutilsOptionError, - DistutilsTemplateError, DistutilsModuleError, - DistutilsFileError) + DistutilsModuleError, DistutilsFileError) from distutils2.manifest import Manifest from distutils2 import logger -from distutils2.util import convert_path, resolve_name +from distutils2.util import resolve_name def show_formats(): """Print all possible values for the 'formats' option (used by @@ -300,7 +296,7 @@ class sdist(Command): for file in files: if not os.path.isfile(file): - logger.warn("'%s' not a regular file -- skipping" % file) + logger.warn("'%s' not a regular file -- skipping", file) else: dest = os.path.join(base_dir, file) self.copy_file(file, dest, link=link) @@ -336,7 +332,7 @@ class sdist(Command): if not self.keep_temp: if self.dry_run: - logger.info('Removing %s' % base_dir) + logger.info('Removing %s', base_dir) else: rmtree(base_dir) diff --git a/distutils2/compiler/msvc9compiler.py b/distutils2/compiler/msvc9compiler.py index 25e832c..11a17d4 100644 --- a/distutils2/compiler/msvc9compiler.py +++ b/distutils2/compiler/msvc9compiler.py @@ -226,10 +226,10 @@ def find_vcvarsall(version): productdir = os.path.join(toolsdir, os.pardir, os.pardir, "VC") productdir = os.path.abspath(productdir) if not os.path.isdir(productdir): - logger.debug("%s is not a valid directory" % productdir) + logger.debug("%s is not a valid directory", productdir) return None else: - logger.debug("Env var %s is not set or invalid" % toolskey) + logger.debug("Env var %s is not set or invalid", toolskey) if not productdir: logger.debug("No productdir found") return None diff --git a/distutils2/config.py b/distutils2/config.py index b8bbae1..6b9963e 100644 --- a/distutils2/config.py +++ b/distutils2/config.py @@ -3,8 +3,8 @@ Know how to read all config files Distutils2 uses. """ import os -import re import sys +import logging from ConfigParser import RawConfigParser from shlex import split @@ -90,7 +90,8 @@ class Config(object): if os.path.isfile(local_file): files.append(local_file) - logger.debug("using config files: %s" % ', '.join(files)) + if logger.isEnabledFor(logging.DEBUG): + logger.debug("using config files: %s", ', '.join(files)) return files def _convert_metadata(self, name, value): @@ -168,7 +169,7 @@ class Config(object): files = dict([(key, _convert(key, value)) for key, value in content['files'].iteritems()]) self.dist.packages = [] - self.dist.package_dir = pkg_dir = files.get('packages_root') + self.dist.package_dir = files.get('packages_root') packages = files.get('packages', []) if isinstance(packages, str): @@ -241,7 +242,7 @@ class Config(object): parser = RawConfigParser() for filename in filenames: - logger.debug(" reading %s" % filename) + logger.debug(" reading %s", filename) parser.read(filename) if os.path.split(filename)[-1] == 'setup.cfg': diff --git a/distutils2/dist.py b/distutils2/dist.py index 9466935..b80dc9a 100644 --- a/distutils2/dist.py +++ b/distutils2/dist.py @@ -293,10 +293,10 @@ Common commands: (see '--help-commands' for more) opt_dict = self.command_options.get(cmd_name) if opt_dict is None: self.announce(indent + - "no option dict for '%s' command" % cmd_name) + "no option dict for %r command" % cmd_name) else: self.announce(indent + - "option dict for '%s' command:" % cmd_name) + "option dict for %r command:" % cmd_name) out = pformat(opt_dict) for line in out.split('\n'): self.announce(indent + " " + line) @@ -401,7 +401,7 @@ Common commands: (see '--help-commands' for more) # Pull the current command from the head of the command line command = args[0] if not command_re.match(command): - raise SystemExit("invalid command name '%s'" % command) + raise SystemExit("invalid command name %r" % command) self.commands.append(command) # Dig up the command class that implements this command, so we @@ -420,15 +420,15 @@ Common commands: (see '--help-commands' for more) if hasattr(cmd_class, meth): continue raise DistutilsClassError( - 'command "%s" must implement "%s"' % (cmd_class, meth)) + 'command %r must implement %r' % (cmd_class, meth)) # Also make sure that the command object provides a list of its # known options. if not (hasattr(cmd_class, 'user_options') and isinstance(cmd_class.user_options, list)): raise DistutilsClassError( - ("command class %s must provide " - "'user_options' attribute (a list of tuples)") % cmd_class) + "command class %s must provide " + "'user_options' attribute (a list of tuples)" % cmd_class) # If the command class has a list of negative alias options, # merge it in with the global negative aliases. @@ -466,7 +466,7 @@ Common commands: (see '--help-commands' for more) func() else: raise DistutilsClassError( - "invalid help function %r for help option '%s': " + "invalid help function %r for help option %r: " "must be a callable object (function, etc.)" % (func, help_option)) @@ -537,7 +537,7 @@ Common commands: (see '--help-commands' for more) fix_help_options(cls.help_options)) else: parser.set_option_table(cls.user_options) - parser.print_help("Options for '%s' command:" % cls.__name__) + parser.print_help("Options for %r command:" % cls.__name__) print('') print(gen_usage(self.script_name)) @@ -639,7 +639,7 @@ Common commands: (see '--help-commands' for more) cmd_obj = self.command_obj.get(command) if not cmd_obj and create: logger.debug("Distribution.get_command_obj(): " \ - "creating '%s' command object" % command) + "creating %r command object", command) cls = get_command_class(command) cmd_obj = self.command_obj[command] = cls(self) @@ -669,10 +669,10 @@ Common commands: (see '--help-commands' for more) if option_dict is None: option_dict = self.get_option_dict(command_name) - logger.debug(" setting options for '%s' command:" % command_name) + logger.debug(" setting options for %r command:", command_name) for (option, (source, value)) in option_dict.iteritems(): - logger.debug(" %s = %s (from %s)" % (option, value, source)) + logger.debug(" %s = %s (from %s)", option, value, source) try: bool_opts = [x.replace('-', '_') for x in command_obj.boolean_options] @@ -693,7 +693,7 @@ Common commands: (see '--help-commands' for more) setattr(command_obj, option, value) else: raise DistutilsOptionError( - "error in %s: command '%s' has no such option '%s'" % + "error in %s: command %r has no such option %r" % (source, command_name, option)) except ValueError, msg: raise DistutilsOptionError(msg) diff --git a/distutils2/index/simple.py b/distutils2/index/simple.py index cd88698..dc1f74c 100644 --- a/distutils2/index/simple.py +++ b/distutils2/index/simple.py @@ -11,7 +11,6 @@ import socket import sys import urllib2 import urlparse -import logging import os from distutils2 import logger @@ -168,7 +167,7 @@ class Crawler(BaseClient): if predicate.name.lower() in self._projects and not force_update: return self._projects.get(predicate.name.lower()) prefer_final = self._get_prefer_final(prefer_final) - logger.info('Reading info on PyPI about %s' % predicate.name) + logger.info('Reading info on PyPI about %s', predicate.name) self._process_index_page(predicate.name) if predicate.name.lower() not in self._projects: @@ -306,8 +305,8 @@ class Crawler(BaseClient): infos = get_infos_from_url(link, project_name, is_external=not self.index_url in url) except CantParseArchiveName, e: - logging.warning("version has not been parsed: %s" - % e) + logger.warning( + "version has not been parsed: %s", e) else: self._register_release(release_info=infos) else: diff --git a/distutils2/index/xmlrpc.py b/distutils2/index/xmlrpc.py index 54d7367..2a8cb66 100644 --- a/distutils2/index/xmlrpc.py +++ b/distutils2/index/xmlrpc.py @@ -165,7 +165,7 @@ class Client(BaseClient): p['version'], metadata={'summary': p['summary']}, index=self._index)) except IrrationalVersionError, e: - logging.warn("Irrational version error found: %s" % e) + logging.warn("Irrational version error found: %s", e) return [self._projects[p['name'].lower()] for p in projects] def get_all_projects(self): diff --git a/distutils2/install.py b/distutils2/install.py index 4d3ea5a..8da7c28 100644 --- a/distutils2/install.py +++ b/distutils2/install.py @@ -12,6 +12,7 @@ import sys import stat import errno import itertools +import logging import tempfile from distutils2 import logger @@ -134,12 +135,12 @@ def install_dists(dists, path, paths=sys.path): installed_dists, installed_files = [], [] for dist in dists: - logger.info('Installing %s %s' % (dist.name, dist.version)) + logger.info('Installing %s %s', dist.name, dist.version) try: installed_files.extend(_install_dist(dist, path)) installed_dists.append(dist) except Exception, e: - logger.info('Failed. %s' % str(e)) + logger.info('Failed. %s', e) # reverting for installed_dist in installed_dists: @@ -258,8 +259,8 @@ def get_infos(requirements, index=None, installed=None, prefer_final=True): if predicate.name.lower() != installed_project.name.lower(): continue found = True - logger.info('Found %s %s' % (installed_project.name, - installed_project.version)) + logger.info('Found %s %s', installed_project.name, + installed_project.version) # if we already have something installed, check it matches the # requirements @@ -358,7 +359,7 @@ def remove(project_name, paths=sys.path): finally: shutil.rmtree(tmp) - logger.info('Removing %r...' % project_name) + logger.info('Removing %r...', project_name) file_count = 0 for file_ in rmfiles: @@ -391,16 +392,16 @@ def remove(project_name, paths=sys.path): if os.path.exists(dist.path): shutil.rmtree(dist.path) - logger.info('Success ! Removed %d files and %d dirs' % \ - (file_count, dir_count)) + logger.info('Success! Removed %d files and %d dirs', + file_count, dir_count) def install(project): - logger.info('Getting information about "%s".' % project) + logger.info('Getting information about "%s".', project) try: info = get_infos(project) except InstallationException: - logger.info('Cound not find "%s".' % project) + logger.info('Cound not find "%s".', project) return if info['install'] == []: @@ -413,8 +414,9 @@ def install(project): info['install'], info['remove'], info['conflict']) except InstallationConflict, e: - projects = ['%s %s' % (p.name, p.version) for p in e.args[0]] - logger.info('"%s" conflicts with "%s"' % (project, ','.join(projects))) + if logger.isEnabledFor(logging.INFO): + projects = ['%s %s' % (p.name, p.version) for p in e.args[0]] + logger.info('%r conflicts with %s', project, ','.join(projects)) def _main(**attrs): diff --git a/distutils2/manifest.py b/distutils2/manifest.py index e5862dd..2ea1a0d 100644 --- a/distutils2/manifest.py +++ b/distutils2/manifest.py @@ -95,7 +95,7 @@ class Manifest(object): try: self._process_template_line(line) except DistutilsTemplateError, msg: - logging.warning("%s, %s" % (path_or_file, msg)) + logging.warning("%s, %s", path_or_file, msg) def write(self, path): """Write the file list in 'self.filelist' (presumably as filled in @@ -111,14 +111,14 @@ class Manifest(object): if first_line != '# file GENERATED by distutils, do NOT edit\n': logging.info("not writing to manually maintained " - "manifest file '%s'", path) + "manifest file %r", path) return self.sort() self.remove_duplicates() content = self.files[:] content.insert(0, '# file GENERATED by distutils, do NOT edit') - logging.info("writing manifest file '%s'", path) + logging.info("writing manifest file %r", path) write_file(path, content) def read(self, path): @@ -126,7 +126,7 @@ class Manifest(object): fill in 'self.filelist', the list of files to include in the source distribution. """ - logging.info("reading manifest file '%s'" % path) + logging.info("reading manifest file %r", path) manifest = open(path) try: for line in manifest.readlines(): @@ -168,14 +168,14 @@ class Manifest(object): 'global-include', 'global-exclude'): if len(words) < 2: raise DistutilsTemplateError( - "'%s' expects <pattern1> <pattern2> ..." % action) + "%r expects <pattern1> <pattern2> ..." % action) patterns = map(convert_path, words[1:]) elif action in ('recursive-include', 'recursive-exclude'): if len(words) < 3: raise DistutilsTemplateError( - "'%s' expects <dir> <pattern1> <pattern2> ..." % action) + "%r expects <dir> <pattern1> <pattern2> ..." % action) dir = convert_path(words[1]) patterns = map(convert_path, words[2:]) @@ -183,12 +183,12 @@ class Manifest(object): elif action in ('graft', 'prune'): if len(words) != 2: raise DistutilsTemplateError( - "'%s' expects a single <dir_pattern>" % action) + "%r expects a single <dir_pattern>" % action) dir_pattern = convert_path(words[1]) else: - raise DistutilsTemplateError("unknown action '%s'" % action) + raise DistutilsTemplateError("unknown action %r" % action) return action, patterns, dir, dir_pattern @@ -206,53 +206,53 @@ class Manifest(object): if action == 'include': for pattern in patterns: if not self._include_pattern(pattern, anchor=1): - logging.warning("warning: no files found matching '%s'" % - pattern) + logging.warning("warning: no files found matching %r", + pattern) elif action == 'exclude': for pattern in patterns: if not self.exclude_pattern(pattern, anchor=1): - logging.warning(("warning: no previously-included files " - "found matching '%s'") % pattern) + logging.warning("warning: no previously-included files " + "found matching %r", pattern) elif action == 'global-include': for pattern in patterns: if not self._include_pattern(pattern, anchor=0): - logging.warning(("warning: no files found matching '%s' " + - "anywhere in distribution") % pattern) + logging.warning("warning: no files found matching %r " + "anywhere in distribution", pattern) elif action == 'global-exclude': for pattern in patterns: if not self.exclude_pattern(pattern, anchor=0): - logging.warning(("warning: no previously-included files " - "matching '%s' found anywhere in distribution") % - pattern) + logging.warning("warning: no previously-included files " + "matching %r found anywhere in " + "distribution", pattern) elif action == 'recursive-include': for pattern in patterns: if not self._include_pattern(pattern, prefix=dir): - logging.warning(("warning: no files found matching '%s' " - "under directory '%s'" % (pattern, dir))) + logging.warning("warning: no files found matching %r " + "under directory %r", pattern, dir) elif action == 'recursive-exclude': for pattern in patterns: if not self.exclude_pattern(pattern, prefix=dir): - logging.warning(("warning: no previously-included files " - "matching '%s' found under directory '%s'") % - (pattern, dir)) + logging.warning("warning: no previously-included files " + "matching %r found under directory %r", + pattern, dir) elif action == 'graft': if not self._include_pattern(None, prefix=dir_pattern): - logging.warning("warning: no directories found matching '%s'" % - dir_pattern) + logging.warning("warning: no directories found matching %r", + dir_pattern) elif action == 'prune': if not self.exclude_pattern(None, prefix=dir_pattern): - logging.warning(("no previously-included directories found " + - "matching '%s'") % dir_pattern) + logging.warning("no previously-included directories found " + "matching %r", dir_pattern) else: raise DistutilsInternalError( - "this cannot happen: invalid action '%s'" % action) + "this cannot happen: invalid action %r" % action) def _include_pattern(self, pattern, anchor=1, prefix=None, is_regex=0): """Select strings (presumably filenames) from 'self.files' that diff --git a/distutils2/tests/support.py b/distutils2/tests/support.py index b4c039c..4f16d08 100644 --- a/distutils2/tests/support.py +++ b/distutils2/tests/support.py @@ -51,6 +51,9 @@ class LoggingCatcher(object): def setUp(self): super(LoggingCatcher, self).setUp() + # TODO read the new logging docs and/or the python-dev posts about + # logging and tests to properly use a handler instead of + # monkey-patching self.old_log = logger._log logger._log = self._log logger.setLevel(logging.INFO) diff --git a/distutils2/tests/test_command_build_py.py b/distutils2/tests/test_command_build_py.py index 38ff7a6..6d30eee 100644 --- a/distutils2/tests/test_command_build_py.py +++ b/distutils2/tests/test_command_build_py.py @@ -116,7 +116,7 @@ class BuildPyTestCase(support.TempdirManager, finally: sys.dont_write_bytecode = old_dont_write_bytecode - self.assertTrue('byte-compiling is disabled' in self.logs[0][1]) + self.assertIn('byte-compiling is disabled', self.logs[0][2][1]) def test_suite(): return unittest.makeSuite(BuildPyTestCase) diff --git a/distutils2/tests/test_command_install_lib.py b/distutils2/tests/test_command_install_lib.py index 7fb4e7a..d0d7ec8 100644 --- a/distutils2/tests/test_command_install_lib.py +++ b/distutils2/tests/test_command_install_lib.py @@ -97,7 +97,7 @@ class InstallLibTestCase(support.TempdirManager, finally: sys.dont_write_bytecode = old_dont_write_bytecode - self.assertTrue('byte-compiling is disabled' in self.logs[0][1]) + self.assertIn('byte-compiling is disabled', self.logs[0][2][1]) def test_suite(): return unittest.makeSuite(InstallLibTestCase) diff --git a/distutils2/tests/test_command_sdist.py b/distutils2/tests/test_command_sdist.py index cdb0595..4f74876 100644 --- a/distutils2/tests/test_command_sdist.py +++ b/distutils2/tests/test_command_sdist.py @@ -95,9 +95,6 @@ class SDistTestCase(support.TempdirManager, support.LoggingCatcher, dist.include_package_data = True cmd = sdist(dist) cmd.dist_dir = 'dist' - def _warn(*args): - pass - cmd.warn = _warn return dist, cmd @unittest.skipUnless(zlib, "requires zlib") @@ -251,7 +248,7 @@ class SDistTestCase(support.TempdirManager, support.LoggingCatcher, cmd.ensure_finalized() cmd.run() warnings = self.get_logs(logging.WARN) - self.assertEqual(len(warnings), 1) + self.assertEqual(len(warnings), 2) # trying with a complete set of metadata self.clear_logs() @@ -263,7 +260,8 @@ class SDistTestCase(support.TempdirManager, support.LoggingCatcher, # removing manifest generated warnings warnings = [warn for warn in warnings if not warn.endswith('-- skipping')] - self.assertEqual(len(warnings), 0) + # the remaining warning is about the use of the default file list + self.assertEqual(len(warnings), 1) def test_show_formats(self): diff --git a/distutils2/tests/test_manifest.py b/distutils2/tests/test_manifest.py index 5f768eb..8b77cc9 100644 --- a/distutils2/tests/test_manifest.py +++ b/distutils2/tests/test_manifest.py @@ -1,6 +1,5 @@ """Tests for distutils.manifest.""" import os -import sys import logging from StringIO import StringIO @@ -25,10 +24,11 @@ file1 class ManifestTestCase(support.TempdirManager, + # enable this after LoggingCatcher is fixed + #support.LoggingCatcher, unittest.TestCase): def test_manifest_reader(self): - tmpdir = self.mkdtemp() MANIFEST = os.path.join(tmpdir, 'MANIFEST.in') f = open(MANIFEST, 'w') @@ -38,9 +38,10 @@ class ManifestTestCase(support.TempdirManager, f.close() manifest = Manifest() + # remove this when LoggingCatcher is fixed warns = [] - def _warn(msg): - warns.append(msg) + def _warn(*args): + warns.append(args[0]) old_warn = logging.warning logging.warning = _warn |
