Add PEP8 check and fix related issues

- Add PEP8 section to tox.ini
- Add requirements.txt
- Add hacking to requirements to enforce OpenStack style requirements
- Fix formatting issues flagged by flake8 check
- Add copyright notices to all remaining files
- Update .gitignore file

Change-Id: I82cd4377d5eaded1a39fe0349105582fd42779d1
This commit is contained in:
Levi Blackstone 2015-05-05 09:10:26 -05:00
parent f5bc8c2a13
commit b0caa41138
7 changed files with 70 additions and 17 deletions

5
.gitignore vendored
View File

@ -34,3 +34,8 @@ nosetests.xml
.mr.developer.cfg
.project
.pydevproject
# IDE Project Files
*.project
*.pydev*
*.idea

1
requirements.txt Normal file
View File

@ -0,0 +1 @@
hacking>=0.10.0,<0.11

View File

@ -75,8 +75,8 @@ 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:
@ -95,8 +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)

View File

@ -1,3 +1,19 @@
# Copyright (c) 2014 Dark Secret Software Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class Foo(object):
def method_a(self, a, b, c, d):
pass

View File

@ -1,3 +1,19 @@
# Copyright (c) 2014 Dark Secret Software Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class Foo(object):
def method_a(self, a, b, c, d):
pass

View File

@ -1,3 +1,18 @@
# Copyright (c) 2014 Dark Secret Software Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
import unittest
@ -40,9 +55,9 @@ class TestSimport(unittest.TestCase):
self.assertFalse("AnyModuleName" in sys.modules)
def test_good_external_targets(self):
self.assertEquals(("localmodule", "Foo", "method_a"),
simport._get_module("tests|"
"localmodule:Foo.method_a"))
self.assertEqual(("localmodule", "Foo", "method_a"),
simport._get_module("tests|"
"localmodule:Foo.method_a"))
self.assertRaises(simport.ImportFailed, simport._get_module,
"tests|that_module:function_a")
@ -52,18 +67,19 @@ class TestSimport(unittest.TestCase):
"test_simport:missing")
def test_good_load_internal(self):
self.assertEquals(dummy_function,
simport.load("test_simport:dummy_function"))
self.assertEquals(DummyClass.method_a,
simport.load("test_simport:DummyClass.method_a"))
self.assertEqual(dummy_function,
simport.load("test_simport:dummy_function"))
self.assertEqual(DummyClass.method_a,
simport.load("test_simport:DummyClass.method_a"))
def test_good_load_local(self):
method = simport.load("tests|"
"localmodule:Foo.method_a")
import localmodule
self.assertEquals(method, localmodule.Foo.method_a)
self.assertEquals(localmodule.function_a,
simport.load("localmodule:function_a"))
self.assertEqual(method, localmodule.Foo.method_a)
self.assertEqual(localmodule.function_a,
simport.load("localmodule:function_a"))
def test_good_load_external(self):
method = simport.load("tests/external|"
@ -82,6 +98,7 @@ class TestSimport(unittest.TestCase):
klass = simport.load("tests/external|"
"external.externalmodule:Blah")
import external.externalmodule
self.assertEqual(klass, external.externalmodule.Blah)
def test_local_class(self):

View File

@ -3,12 +3,10 @@ envlist = py26,py27,pep8
[testenv]
deps =
-r{toxinidir}/requirements.txt
coverage
nose
mock
flake8
setenv = VIRTUAL_ENV={envdir}
commands = nosetests -d -v --with-coverage --cover-inclusive --cover-package simport []