diff options
author | Erik Rose <devnull@localhost> | 2014-03-19 02:10:30 -0400 |
---|---|---|
committer | Erik Rose <devnull@localhost> | 2014-03-19 02:10:30 -0400 |
commit | 728836407ea8c81abc5fc33b1b88af7d00a8b7d0 (patch) | |
tree | e24327ad6877bc74e8dbe52a603a32a4ed30f690 | |
parent | e94580988e6882c90f13af1370510049deca5618 (diff) | |
download | six-728836407ea8c81abc5fc33b1b88af7d00a8b7d0.tar.gz |
Stop referencing deleted private attrs in test_dictionary_iterators.
-rw-r--r-- | test_six.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/test_six.py b/test_six.py index 47ad1ce..9e39444 100644 --- a/test_six.py +++ b/test_six.py @@ -353,6 +353,14 @@ def test_get_function_globals(): def test_dictionary_iterators(monkeypatch): + def stock_method_name(iterwhat): + """Given a method suffix like "lists" or "values", return the name + of the dict method that delivers those on the version of Python + we're running in.""" + if six.PY3: + return iterwhat + return 'iter' + iterwhat + class MyDict(dict): if not six.PY3: def lists(self, **kw): @@ -361,7 +369,8 @@ def test_dictionary_iterators(monkeypatch): return iter([1, 2, 3]) f = MyDict.iterlists del MyDict.iterlists - setattr(MyDict, six._iterlists, f) + setattr(MyDict, stock_method_name('lists'), f) + d = MyDict(zip(range(10), reversed(range(10)))) for name in "keys", "values", "items", "lists": meth = getattr(six, "iter" + name) @@ -373,8 +382,8 @@ def test_dictionary_iterators(monkeypatch): def with_kw(*args, **kw): record.append(kw["kw"]) return old(*args) - old = getattr(MyDict, getattr(six, "_iter" + name)) - monkeypatch.setattr(MyDict, getattr(six, "_iter" + name), with_kw) + old = getattr(MyDict, stock_method_name(name)) + monkeypatch.setattr(MyDict, stock_method_name(name), with_kw) meth(d, kw=42) assert record == [42] monkeypatch.undo() |