diff options
| author | Pierre-Yves Chibon <pingou@pingoured.fr> | 2015-07-28 11:19:49 +0000 |
|---|---|---|
| committer | Patrick Uiterwijk <puiterwijk@redhat.com> | 2015-08-11 12:08:50 +0200 |
| commit | ce2bbec3f2a010cfa26363a91a6224efe484f06f (patch) | |
| tree | 0195f3654105f7a1e6b72743322c024c4717718b /tests | |
| parent | db9da225bce11ddeef1b5a2d511f18e17a808f15 (diff) | |
| download | ipsilon-ce2bbec3f2a010cfa26363a91a6224efe484f06f.tar.gz ipsilon-ce2bbec3f2a010cfa26363a91a6224efe484f06f.tar.xz ipsilon-ce2bbec3f2a010cfa26363a91a6224efe484f06f.zip | |
Drop all the calls to .keys() when iterating on the keys of a dict
When browsing the keys of a dictionary, you can use the ``.keys()`` method but
that is in fact only really useful if you want to store the list of keys first
and act on them (like sorting them or so).
If you just want to iterate through all the keys, no matter the order, then it
is much much faster to just do: ``for key in dict``
Some stats about this can be found there:
http://blog.pingoured.fr/index.php?post/2012/03/12/Python-notes-to-self
Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
Reviewed-by: Simo Sorce <simo@redhat.com>
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/helpers/common.py | 4 | ||||
| -rwxr-xr-x | tests/testmapping.py | 2 | ||||
| -rwxr-xr-x | tests/testnameid.py | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/tests/helpers/common.py b/tests/helpers/common.py index cbd516b..eadfdc3 100755 --- a/tests/helpers/common.py +++ b/tests/helpers/common.py @@ -101,10 +101,10 @@ class IpsilonTestBase(object): nameid='unspecified'): newconf = ConfigParser.ConfigParser() newconf.add_section('globals') - for k in global_opts.keys(): + for k in global_opts: newconf.set('globals', k, global_opts[k]) newconf.add_section('arguments') - for k in args_opts.keys(): + for k in args_opts: newconf.set('arguments', k, args_opts[k]) profile = io.BytesIO() diff --git a/tests/testmapping.py b/tests/testmapping.py index 6c3ae7d..64a31cd 100755 --- a/tests/testmapping.py +++ b/tests/testmapping.py @@ -85,7 +85,7 @@ def check_info_plugin(s, idp_name, urlbase, expected): data.pop('MELLON_IDP') data.pop('MELLON_NAME_ID') - for key in expected.keys(): + for key in expected: item = data.pop('MELLON_' + key) if item != expected[key]: raise ValueError('Expected %s, got %s' % (expected[key], item)) diff --git a/tests/testnameid.py b/tests/testnameid.py index 4121e11..ffbbeac 100755 --- a/tests/testnameid.py +++ b/tests/testnameid.py @@ -55,7 +55,7 @@ def generate_sp_list(): splist = [] spport = 45081 - for nameid in SAML2_NAMEID_MAP.keys(): + for nameid in SAML2_NAMEID_MAP: nameid = nameid spdata = {'nameid': nameid, 'addr': '127.0.0.11', 'port': str(spport)} splist.append(spdata) |
