[Python-checkins] distutils2: removed unused warnings & refactored a test to use WarningsCatcher
tarek.ziade
python-checkins at python.org
Sun Sep 19 10:20:22 CEST 2010
tarek.ziade pushed fb727ebb8c5d to distutils2:
http://hg.python.org/distutils2/rev/fb727ebb8c5d
changeset: 641:fb727ebb8c5d
user: Konrad Delong <konryd at gmail.com>
date: Sun Aug 15 21:09:14 2010 +0200
summary: removed unused warnings & refactored a test to use WarningsCatcher
files: src/distutils2/tests/test_dist.py, src/distutils2/tests/test_emxccompiler.py, src/distutils2/tests/test_extension.py, src/distutils2/tests/test_register.py, src/distutils2/tests/test_sdist.py
diff --git a/src/distutils2/tests/test_dist.py b/src/distutils2/tests/test_dist.py
--- a/src/distutils2/tests/test_dist.py
+++ b/src/distutils2/tests/test_dist.py
@@ -4,7 +4,6 @@
import os
import StringIO
import sys
-import warnings
import textwrap
from distutils2.dist import Distribution, fix_help_options, DistributionMetadata
@@ -172,23 +171,13 @@
# list of attributes
cls = Distribution
- # catching warnings
- warns = []
- def _warn(msg):
- warns.append(msg)
+ dist = cls(attrs={'author': 'xxx',
+ 'name': 'xxx',
+ 'version': 'xxx',
+ 'url': 'xxxx',
+ 'options': {}})
- old_warn = warnings.warn
- warnings.warn = _warn
- try:
- dist = cls(attrs={'author': 'xxx',
- 'name': 'xxx',
- 'version': 'xxx',
- 'url': 'xxxx',
- 'options': {}})
- finally:
- warnings.warn = old_warn
-
- self.assertEqual(len(warns), 0)
+ self.assertEqual(len(self.warnings), 0)
def test_non_empty_options(self):
# TODO: how to actually use options is not documented except
@@ -314,7 +303,7 @@
('post', cmd)])
class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
- unittest.TestCase):
+ support.LoggingSilencer, unittest.TestCase):
def setUp(self):
super(MetadataTestCase, self).setUp()
diff --git a/src/distutils2/tests/test_emxccompiler.py b/src/distutils2/tests/test_emxccompiler.py
--- a/src/distutils2/tests/test_emxccompiler.py
+++ b/src/distutils2/tests/test_emxccompiler.py
@@ -1,7 +1,6 @@
"""Tests for distutils.emxccompiler."""
import sys
import os
-import warnings
from distutils2.tests import run_unittest
from distutils2.tests import captured_stdout
diff --git a/src/distutils2/tests/test_extension.py b/src/distutils2/tests/test_extension.py
--- a/src/distutils2/tests/test_extension.py
+++ b/src/distutils2/tests/test_extension.py
@@ -1,6 +1,5 @@
"""Tests for distutils.extension."""
import os
-import warnings
from distutils2.extension import Extension
from distutils2.tests.support import unittest
diff --git a/src/distutils2/tests/test_register.py b/src/distutils2/tests/test_register.py
--- a/src/distutils2/tests/test_register.py
+++ b/src/distutils2/tests/test_register.py
@@ -4,7 +4,6 @@
import os
import getpass
import urllib2
-import warnings
try:
import docutils
diff --git a/src/distutils2/tests/test_sdist.py b/src/distutils2/tests/test_sdist.py
--- a/src/distutils2/tests/test_sdist.py
+++ b/src/distutils2/tests/test_sdist.py
@@ -20,7 +20,6 @@
from os.path import join
import sys
-import warnings
from distutils2.tests import captured_stdout
--
Repository URL: http://hg.python.org/distutils2
More information about the Python-checkins
mailing list