From 063ff65e2c305a8f24100475cc4f9ad2bcc342be Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Fri, 6 Feb 2009 03:01:24 +0000 Subject: Merged revisions 69141,69211-69212 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r69141 | benjamin.peterson | 2009-01-31 14:01:48 -0600 (Sat, 31 Jan 2009) | 1 line fix indentation ........ r69211 | guilherme.polo | 2009-02-02 14:23:29 -0600 (Mon, 02 Feb 2009) | 1 line Restore the previous geometry before leaving the test ........ r69212 | guilherme.polo | 2009-02-02 14:28:59 -0600 (Mon, 02 Feb 2009) | 1 line Moving to importlib ........ --- Doc/library/itertools.rst | 46 ++++++++++++++-------------- Lib/tkinter/test/runtktests.py | 10 ++---- Lib/tkinter/test/test_ttk/test_extensions.py | 5 +-- 3 files changed, 29 insertions(+), 32 deletions(-) diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst index 634b909..8346587 100644 --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -654,26 +654,26 @@ which incur interpreter overhead. s = list(iterable) return chain.from_iterable(combinations(s, r) for r in range(len(s)+1)) - def unique_everseen(iterable, key=None): - "List unique elements, preserving order. Remember all elements ever seen." - # unique_everseen('AAAABBBCCDAABBB') --> A B C D - # unique_everseen('ABBCcAD', str.lower) --> A B C D - seen = set() - seen_add = seen.add - if key is None: - for element in iterable: - if element not in seen: - seen_add(element) - yield element - else: - for element in iterable: - k = key(element) - if k not in seen: - seen_add(k) - yield element - - def unique_justseen(iterable, key=None): - "List unique elements, preserving order. Remember only the element just seen." - # unique_justseen('AAAABBBCCDAABBB') --> A B C D A B - # unique_justseen('ABBCcAD', str.lower) --> A B C A D - return map(next, map(itemgetter(1), groupby(iterable, key))) + def unique_everseen(iterable, key=None): + "List unique elements, preserving order. Remember all elements ever seen." + # unique_everseen('AAAABBBCCDAABBB') --> A B C D + # unique_everseen('ABBCcAD', str.lower) --> A B C D + seen = set() + seen_add = seen.add + if key is None: + for element in iterable: + if element not in seen: + seen_add(element) + yield element + else: + for element in iterable: + k = key(element) + if k not in seen: + seen_add(k) + yield element + + def unique_justseen(iterable, key=None): + "List unique elements, preserving order. Remember only the element just seen." + # unique_justseen('AAAABBBCCDAABBB') --> A B C D A B + # unique_justseen('ABBCcAD', str.lower) --> A B C A D + return map(next, imap(itemgetter(1), groupby(iterable, key))) diff --git a/Lib/tkinter/test/runtktests.py b/Lib/tkinter/test/runtktests.py index 7067594..3d9775b 100644 --- a/Lib/tkinter/test/runtktests.py +++ b/Lib/tkinter/test/runtktests.py @@ -9,6 +9,7 @@ Extensions also should live in packages following the same rule as above. import os import sys import unittest +import importlib import test.support this_dir_path = os.path.abspath(os.path.dirname(__file__)) @@ -44,13 +45,8 @@ def get_tests_modules(basepath=this_dir_path, gui=True, packages=None): for name in filenames: try: - yield __import__( - "%s.%s.%s" % ( - "tkinter.test", - pkg_name, - name[:-len(py_ext)]), - fromlist=[''] - ) + yield importlib.import_module( + ".%s" % name[:-len(py_ext)], pkg_name) except test.support.ResourceDenied: if gui: raise diff --git a/Lib/tkinter/test/test_ttk/test_extensions.py b/Lib/tkinter/test/test_ttk/test_extensions.py index a14ccca..9e52fc6 100644 --- a/Lib/tkinter/test/test_ttk/test_extensions.py +++ b/Lib/tkinter/test/test_ttk/test_extensions.py @@ -167,14 +167,15 @@ class LabeledScaleTest(unittest.TestCase): x.update() width, height = x.master.winfo_width(), x.master.winfo_height() - width, height = width * 2, height * 2 + width_new, height_new = width * 2, height * 2 x.value = 3 x.update() - x.master.wm_geometry("%dx%d" % (width, height)) + x.master.wm_geometry("%dx%d" % (width_new, height_new)) self.failUnlessEqual(int(x.label.place_info()['x']), x.scale.coords()[0]) + # Reset geometry x.master.wm_geometry("%dx%d" % (width, height)) x.destroy() -- cgit v0.12