From b4dea46d8b634fdfd3402b0caffa10d67461d281 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 6 Apr 2014 21:28:44 +0300 Subject: [PATCH] tests: Fix few tests which depend on order of elements in dict. With dict being unordered of course. --- tests/basics/dict_clear.py | 2 +- tests/basics/dict_iterator.py | 4 +++- tests/basics/dict_popitem.py | 15 ++++++++++----- tests/basics/dict_update.py | 2 +- tests/basics/iter-of-iter.py | 2 +- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/tests/basics/dict_clear.py b/tests/basics/dict_clear.py index 6be2778bea..575a848308 100644 --- a/tests/basics/dict_clear.py +++ b/tests/basics/dict_clear.py @@ -1,5 +1,5 @@ d = {1: 2, 3: 4} -print(d) +print(len(d)) d.clear() print(d) d[2] = 42 diff --git a/tests/basics/dict_iterator.py b/tests/basics/dict_iterator.py index f190e32ffd..b3df2ec020 100644 --- a/tests/basics/dict_iterator.py +++ b/tests/basics/dict_iterator.py @@ -1,3 +1,5 @@ d = {1: 2, 3: 4} +els = [] for i in d: - print(i, d[i]) + els.append((i, d[i])) +print(sorted(els)) diff --git a/tests/basics/dict_popitem.py b/tests/basics/dict_popitem.py index 184735cde6..e37bcec19e 100644 --- a/tests/basics/dict_popitem.py +++ b/tests/basics/dict_popitem.py @@ -1,11 +1,16 @@ -d={1:2,3:4} -print(d.popitem()) -print(d) -print(d.popitem()) -print(d) +els = [] +d = {1:2,3:4} +a = d.popitem() +print(len(d)) +els.append(a) +a = d.popitem() +print(len(d)) +els.append(a) try: print(d.popitem(), "!!!",) except KeyError: print("Raised KeyError") else: print("Did not raise KeyError") +print(sorted(els)) + diff --git a/tests/basics/dict_update.py b/tests/basics/dict_update.py index e7ae0bd965..46d1f41b5f 100644 --- a/tests/basics/dict_update.py +++ b/tests/basics/dict_update.py @@ -1,5 +1,5 @@ d = {1:2, 3:4} -print(d) +print(len(d)) d.update(["ab"]) print(d[1]) print(d[3]) diff --git a/tests/basics/iter-of-iter.py b/tests/basics/iter-of-iter.py index 93368612b8..ba55356294 100644 --- a/tests/basics/iter-of-iter.py +++ b/tests/basics/iter-of-iter.py @@ -3,6 +3,6 @@ print(list(i)) i = iter(iter([1, 2, 3])) print(list(i)) i = iter(iter({1:2, 3:4, 5:6})) -print(list(i)) +print(sorted(i)) i = iter(iter({1, 2, 3})) print(list(i))