From 731fd197e7199a643cf76c34fb91c1125ede9be6 Mon Sep 17 00:00:00 2001 From: Manu Date: Mon, 13 Apr 2015 23:43:10 -0500 Subject: [PATCH] upgraded compatibility to 3.4 and pypy --- json_config/configuration.py | 8 ++++---- requirements.txt | 3 +-- test/test_configuration.py | 2 +- tox.ini | 7 ++++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/json_config/configuration.py b/json_config/configuration.py index c093282..4d188e1 100644 --- a/json_config/configuration.py +++ b/json_config/configuration.py @@ -27,7 +27,8 @@ def connect(config_file_): try: config.update(json.load(open(config_file), object_hook=json_hook)) except IOError: - open(config_file, 'w').close() + with open(config_file, 'w') as f: + f.close() return config @@ -59,8 +60,8 @@ def _wrapper(self, *args, **kwargs): return func(self, *args, **kwargs) finally: - json.dump(config, open(config_file, 'wb'), indent=2, sort_keys=True, - separators=(',', ': ')) + with open(config_file, 'w') as f: + json.dump(config, f, indent=2, sort_keys=True, separators=(',', ': ')) return _wrapper @@ -73,7 +74,6 @@ def __setitem__(self, key, value): def __getitem__(self, key): - print key return super(Configuration, self).__getitem__(key) @save_config diff --git a/requirements.txt b/requirements.txt index 1a9bb6e..06f9cd4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ pytest -wheel -Sphinx +wheel \ No newline at end of file diff --git a/test/test_configuration.py b/test/test_configuration.py index 9f2a733..f097e9f 100755 --- a/test/test_configuration.py +++ b/test/test_configuration.py @@ -48,7 +48,7 @@ def test_abc_magic_methods_length(): def test_abc_magic_methods_iter(config): iter_config = list(config) - assert iter_config == ['test', 'cat_1', 'cat_2', 'cat_3'] + assert set(iter_config) == {'test', 'cat_1', 'cat_2', 'cat_3'} def test_abc_magic_methods_getitem(config): diff --git a/tox.ini b/tox.ini index 29f44ce..2cd49cf 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,10 @@ [tox] -envlist = py27, py34, pypy, style, docs +envlist = py27, py34, pypy, docs +basepython=python2.7 [testenv] commands = - python setup.py test + {envpython} setup.py test setenv= PYTHONWARNINGS=all @@ -12,7 +13,7 @@ deps = -r{toxinidir}/requirements.txt flake8 commands = - python setup.py flake8 + flake8 [testenv:docs] whitelist_externals = make