From f5bc8c2a13f278f61eba77d2878922878cc2b029 Mon Sep 17 00:00:00 2001 From: Monsyne Dragon Date: Mon, 17 Aug 2015 22:41:49 +0000 Subject: [PATCH] Bump dev status Shouldn't be considered pre-release anymore Also fixed pep8 test. Change-Id: I9ad41ce6e60736a944af4195542c409f59e110b2 --- setup.cfg | 4 ++-- simport/__init__.py | 10 ++++++---- tests/test_simport.py | 16 ++++++++-------- tox.ini | 16 ++++++++++++++-- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/setup.cfg b/setup.cfg index 9d1165f..43e79f6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,13 +1,13 @@ [metadata] name = simport -version = 0.2 +version = 0.3 author = Dark Secret Software Inc. author-email = admin@darksecretsoftware.com summary = simple import with python path management description-file = README.md license = Apache-2 classifier = - Development Status :: 3 - Alpha + Development Status :: 5 - Production/Stable Environment :: Console Intended Audience :: Developers Intended Audience :: Information Technology diff --git a/simport/__init__.py b/simport/__init__.py index eae2822..6ba2c98 100644 --- a/simport/__init__.py +++ b/simport/__init__.py @@ -13,7 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -import imp import logging import os import os.path @@ -76,13 +75,15 @@ def _get_module(target): sys.path.append(filepath) if not class_or_function: - raise MissingMethodOrFunction("No Method or Function specified in '%s'" % target) + raise MissingMethodOrFunction("No Method or Function specified in " + "'%s'" % target) if module: try: __import__(module) except ImportError as e: - raise ImportFailed("Failed to import '%s'. Error: %s" % (module, e)) + raise ImportFailed("Failed to import '%s'. " + "Error: %s" % (module, e)) klass, sep, function = class_or_function.rpartition('.') return module, klass, function @@ -94,7 +95,8 @@ def load(target, source_module=None): if not module and source_module: module = source_module if not module: - raise MissingModule("No module name supplied or source_module provided.") + raise MissingModule("No module name supplied or " + "source_module provided.") actual_module = sys.modules[module] if not klass: return getattr(actual_module, function) diff --git a/tests/test_simport.py b/tests/test_simport.py index b026735..1c745dd 100644 --- a/tests/test_simport.py +++ b/tests/test_simport.py @@ -41,21 +41,21 @@ class TestSimport(unittest.TestCase): def test_good_external_targets(self): self.assertEquals(("localmodule", "Foo", "method_a"), - simport._get_module("tests|" - "localmodule:Foo.method_a")) + simport._get_module("tests|" + "localmodule:Foo.method_a")) self.assertRaises(simport.ImportFailed, simport._get_module, "tests|that_module:function_a") def test_bad_load(self): self.assertRaises(AttributeError, simport.load, - "test_simport:missing") + "test_simport:missing") def test_good_load_internal(self): self.assertEquals(dummy_function, - simport.load("test_simport:dummy_function")) + simport.load("test_simport:dummy_function")) self.assertEquals(DummyClass.method_a, - simport.load("test_simport:DummyClass.method_a")) + simport.load("test_simport:DummyClass.method_a")) def test_good_load_local(self): method = simport.load("tests|" @@ -63,11 +63,11 @@ class TestSimport(unittest.TestCase): import localmodule self.assertEquals(method, localmodule.Foo.method_a) self.assertEquals(localmodule.function_a, - simport.load("localmodule:function_a")) + simport.load("localmodule:function_a")) def test_good_load_external(self): method = simport.load("tests/external|" - "external.externalmodule:Blah.method_b") + "external.externalmodule:Blah.method_b") self.assertTrue('external.externalmodule' in sys.modules) old = sys.modules['external.externalmodule'] @@ -80,7 +80,7 @@ class TestSimport(unittest.TestCase): def test_import_class(self): klass = simport.load("tests/external|" - "external.externalmodule:Blah") + "external.externalmodule:Blah") import external.externalmodule self.assertEqual(klass, external.externalmodule.Blah) diff --git a/tox.ini b/tox.ini index 0199909..bf285bd 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,22 @@ [tox] -envlist = py26, py27 +envlist = py26,py27,pep8 [testenv] -deps = +deps = coverage nose mock + flake8 + +setenv = VIRTUAL_ENV={envdir} commands = nosetests -d -v --with-coverage --cover-inclusive --cover-package simport [] + +[testenv:pep8] +commands = + flake8 + +[flake8] +ignore = H405 +exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,timex/__init__.py +show-source = True