Used sets.Set() to compare unordered sequences.

Improves clarity and brevity.
This commit is contained in:
Raymond Hettinger 2003-05-02 09:06:28 +00:00
parent 40006e9f7a
commit 91bbd9a7b9
6 changed files with 17 additions and 40 deletions

View file

@ -2,6 +2,7 @@
import test.test_support, unittest
from test.test_support import fcmp, have_unicode, TESTFN, unlink
from sets import Set
import sys, warnings, cStringIO
warnings.filterwarnings("ignore", "hex../oct.. of negative int",
@ -1159,18 +1160,9 @@ class BuiltinTest(unittest.TestCase):
get_vars_f2 = staticmethod(get_vars_f2)
def test_vars(self):
a = b = None
a = vars().keys()
b = dir()
a.sort()
b.sort()
self.assertEqual(a, b)
self.assertEqual(Set(vars()), Set(dir()))
import sys
a = vars(sys).keys()
b = dir(sys)
a.sort()
b.sort()
self.assertEqual(a, b)
self.assertEqual(Set(vars(sys)), Set(dir(sys)))
self.assertEqual(self.get_vars_f0(), {})
self.assertEqual(self.get_vars_f2(), {'a': 1, 'b': 2})
self.assertRaises(TypeError, vars, 42, 42)