summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-02-02 21:38:37 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-02-02 21:38:37 (GMT)
commitb344dd06c85e5961d5ce99fe9bfd1de10ae66440 (patch)
treefbdf50499b0ce9be7c726bf49203c2444c044e5c /Lib/test
parent65548873cfdef1fbd99a71e84a81283558342d64 (diff)
downloadcpython-b344dd06c85e5961d5ce99fe9bfd1de10ae66440.zip
cpython-b344dd06c85e5961d5ce99fe9bfd1de10ae66440.tar.gz
cpython-b344dd06c85e5961d5ce99fe9bfd1de10ae66440.tar.bz2
Merged revisions 86236,86240,86332,86340,87271,87273,87447 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k The missing NEWS entries correspond to changes that were made before 3.1.3, but I think it’s not usual to edit entries of released versions, so I put them at the top. ........ 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.py35
-rw-r--r--Lib/test/test_tuple.py2
2 files changed, 13 insertions, 24 deletions
diff --git a/Lib/test/test_gettext.py b/Lib/test/test_gettext.py
index 634c607..5456948 100644
--- a/Lib/test/test_gettext.py
+++ b/Lib/test/test_gettext.py
@@ -64,15 +64,12 @@ class GettextBaseTest(unittest.TestCase):
def setUp(self):
if not os.path.isdir(LOCALEDIR):
os.makedirs(LOCALEDIR)
- fp = open(MOFILE, 'wb')
- fp.write(base64.decodebytes(GNU_MO_DATA))
- fp.close()
- fp = open(UMOFILE, 'wb')
- fp.write(base64.decodebytes(UMO_DATA))
- fp.close()
- fp = open(MMOFILE, 'wb')
- fp.write(base64.decodebytes(MMO_DATA))
- fp.close()
+ with open(MOFILE, 'wb') as fp:
+ fp.write(base64.decodebytes(GNU_MO_DATA))
+ with open(UMOFILE, 'wb') as fp:
+ fp.write(base64.decodebytes(UMO_DATA))
+ with open(MMOFILE, 'wb') as fp:
+ fp.write(base64.decodebytes(MMO_DATA))
self.env = support.EnvironmentVarGuard()
self.env['LANGUAGE'] = 'xx'
gettext._translations.clear()
@@ -135,9 +132,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 +223,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 +294,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.gettext
def test_unicode_msgid(self):
@@ -319,15 +311,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 53065bb..f583747 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().test_len()
+ super().test_constructors()
# calling built-in types without argument must return empty
self.assertEqual(tuple(), ())
t0_3 = (0, 1, 2, 3)