diff options
author | Éric Araujo <merwok@netwok.org> | 2011-02-03 00:12:18 +0000 |
---|---|---|
committer | Éric Araujo <merwok@netwok.org> | 2011-02-03 00:12:18 +0000 |
commit | 54274ad96aa033b9f3744dce395d08047467cca9 (patch) | |
tree | 169a1e37a391723c17c3ed8a0c29df97ab9c378d /Lib/test | |
parent | 67843b3886192a1ee31cc12edba2ad41b758c97d (diff) | |
download | cpython-git-54274ad96aa033b9f3744dce395d08047467cca9.tar.gz |
Merged revisions 86236,86240,86332,86340,87271,87273,87447 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
To comply with the 2.x doc style, the methods in trace.rst use brackets around
optional arguments. The rest is a mostly straight merge, modulo support changed
to test_support and use of the old super call style in test_tuple.
........
r86236 | eric.araujo | 2010-11-06 03:44:43 +0100 (sam., 06 nov. 2010) | 2 lines
Make sure each test can be run standalone (./python Lib/distutils/tests/x.py)
........
r86240 | eric.araujo | 2010-11-06 05:11:59 +0100 (sam., 06 nov. 2010) | 2 lines
Prevent ResourceWarnings in test_gettext
........
r86332 | eric.araujo | 2010-11-08 19:15:17 +0100 (lun., 08 nov. 2010) | 4 lines
Add missing NEWS entry for a fix committed by Senthil.
All recent modifications to distutils should now be covered in NEWS.
........
r86340 | eric.araujo | 2010-11-08 22:48:23 +0100 (lun., 08 nov. 2010) | 2 lines
This was actually fixed for the previous alpha.
........
r87271 | eric.araujo | 2010-12-15 20:09:58 +0100 (mer., 15 déc. 2010) | 2 lines
Improve trace documentation (#9264). Patch by Eli Bendersky.
........
r87273 | eric.araujo | 2010-12-15 20:30:15 +0100 (mer., 15 déc. 2010) | 2 lines
Use nested method directives, rewrap long lines, fix whitespace.
........
r87447 | eric.araujo | 2010-12-23 20:13:05 +0100 (jeu., 23 déc. 2010) | 2 lines
Fix typo in superclass method name
........
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_gettext.py | 36 | ||||
-rw-r--r-- | Lib/test/test_tuple.py | 2 |
2 files changed, 14 insertions, 24 deletions
diff --git a/Lib/test/test_gettext.py b/Lib/test/test_gettext.py index 65b395b460..f0369543e0 100644 --- a/Lib/test/test_gettext.py +++ b/Lib/test/test_gettext.py @@ -64,15 +64,13 @@ class GettextBaseTest(unittest.TestCase): def setUp(self): if not os.path.isdir(LOCALEDIR): os.makedirs(LOCALEDIR) - fp = open(MOFILE, 'wb') - fp.write(base64.decodestring(GNU_MO_DATA)) - fp.close() - fp = open(UMOFILE, 'wb') - fp.write(base64.decodestring(UMO_DATA)) - fp.close() - fp = open(MMOFILE, 'wb') - fp.write(base64.decodestring(MMO_DATA)) - fp.close() + with open(MOFILE, 'wb') as fp: + fp.write(base64.decodestring(GNU_MO_DATA)) + with open(UMOFILE, 'wb') as fp: + fp.write(base64.decodestring(UMO_DATA)) + with open(MMOFILE, 'wb') as fp: + fp.write(base64.decodestring(MMO_DATA)) + self.env = test_support.EnvironmentVarGuard() self.env['LANGUAGE'] = 'xx' gettext._translations.clear() @@ -135,9 +133,8 @@ trggrkg zrffntr pngnybt yvoenel.''') def test_the_alternative_interface(self): eq = self.assertEqual # test the alternative interface - fp = open(self.mofile, 'rb') - t = gettext.GNUTranslations(fp) - fp.close() + with open(self.mofile, 'rb') as fp: + t = gettext.GNUTranslations(fp) # Install the translation object t.install() eq(_('nudge nudge'), 'wink wink') @@ -227,9 +224,8 @@ class PluralFormsTestCase(GettextBaseTest): def test_plural_forms2(self): eq = self.assertEqual - fp = open(self.mofile, 'rb') - t = gettext.GNUTranslations(fp) - fp.close() + with open(self.mofile, 'rb') as fp: + t = gettext.GNUTranslations(fp) x = t.ngettext('There is %s file', 'There are %s files', 1) eq(x, 'Hay %s fichero') x = t.ngettext('There is %s file', 'There are %s files', 2) @@ -299,11 +295,8 @@ class PluralFormsTestCase(GettextBaseTest): class UnicodeTranslationsTest(GettextBaseTest): def setUp(self): GettextBaseTest.setUp(self) - fp = open(UMOFILE, 'rb') - try: + with open(UMOFILE, 'rb') as fp: self.t = gettext.GNUTranslations(fp) - finally: - fp.close() self._ = self.t.ugettext def test_unicode_msgid(self): @@ -319,15 +312,12 @@ class UnicodeTranslationsTest(GettextBaseTest): class WeirdMetadataTest(GettextBaseTest): def setUp(self): GettextBaseTest.setUp(self) - fp = open(MMOFILE, 'rb') - try: + with open(MMOFILE, 'rb') as fp: try: self.t = gettext.GNUTranslations(fp) except: self.tearDown() raise - finally: - fp.close() def test_weird_metadata(self): info = self.t.info() diff --git a/Lib/test/test_tuple.py b/Lib/test/test_tuple.py index 4d2137f655..0c308f0e06 100644 --- a/Lib/test/test_tuple.py +++ b/Lib/test/test_tuple.py @@ -6,7 +6,7 @@ class TupleTest(seq_tests.CommonTest): type2test = tuple def test_constructors(self): - super(TupleTest, self).test_len() + super(TupleTest, self).test_constructors() # calling built-in types without argument must return empty self.assertEqual(tuple(), ()) t0_3 = (0, 1, 2, 3) |