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:
parent
f5bc8c2a13
commit
b0caa41138
5
.gitignore
vendored
5
.gitignore
vendored
@ -34,3 +34,8 @@ nosetests.xml
|
|||||||
.mr.developer.cfg
|
.mr.developer.cfg
|
||||||
.project
|
.project
|
||||||
.pydevproject
|
.pydevproject
|
||||||
|
|
||||||
|
# IDE Project Files
|
||||||
|
*.project
|
||||||
|
*.pydev*
|
||||||
|
*.idea
|
||||||
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
hacking>=0.10.0,<0.11
|
@ -75,8 +75,8 @@ def _get_module(target):
|
|||||||
sys.path.append(filepath)
|
sys.path.append(filepath)
|
||||||
|
|
||||||
if not class_or_function:
|
if not class_or_function:
|
||||||
raise MissingMethodOrFunction("No Method or Function specified in "
|
raise MissingMethodOrFunction(
|
||||||
"'%s'" % target)
|
"No Method or Function specified in '%s'" % target)
|
||||||
|
|
||||||
if module:
|
if module:
|
||||||
try:
|
try:
|
||||||
@ -95,8 +95,8 @@ def load(target, source_module=None):
|
|||||||
if not module and source_module:
|
if not module and source_module:
|
||||||
module = source_module
|
module = source_module
|
||||||
if not module:
|
if not module:
|
||||||
raise MissingModule("No module name supplied or "
|
raise MissingModule(
|
||||||
"source_module provided.")
|
"No module name supplied or source_module provided.")
|
||||||
actual_module = sys.modules[module]
|
actual_module = sys.modules[module]
|
||||||
if not klass:
|
if not klass:
|
||||||
return getattr(actual_module, function)
|
return getattr(actual_module, function)
|
||||||
|
16
tests/external/externalmodule.py
vendored
16
tests/external/externalmodule.py
vendored
@ -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):
|
class Foo(object):
|
||||||
def method_a(self, a, b, c, d):
|
def method_a(self, a, b, c, d):
|
||||||
pass
|
pass
|
||||||
|
@ -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):
|
class Foo(object):
|
||||||
def method_a(self, a, b, c, d):
|
def method_a(self, a, b, c, d):
|
||||||
pass
|
pass
|
||||||
|
@ -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 sys
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
@ -40,9 +55,9 @@ class TestSimport(unittest.TestCase):
|
|||||||
self.assertFalse("AnyModuleName" in sys.modules)
|
self.assertFalse("AnyModuleName" in sys.modules)
|
||||||
|
|
||||||
def test_good_external_targets(self):
|
def test_good_external_targets(self):
|
||||||
self.assertEquals(("localmodule", "Foo", "method_a"),
|
self.assertEqual(("localmodule", "Foo", "method_a"),
|
||||||
simport._get_module("tests|"
|
simport._get_module("tests|"
|
||||||
"localmodule:Foo.method_a"))
|
"localmodule:Foo.method_a"))
|
||||||
|
|
||||||
self.assertRaises(simport.ImportFailed, simport._get_module,
|
self.assertRaises(simport.ImportFailed, simport._get_module,
|
||||||
"tests|that_module:function_a")
|
"tests|that_module:function_a")
|
||||||
@ -52,18 +67,19 @@ class TestSimport(unittest.TestCase):
|
|||||||
"test_simport:missing")
|
"test_simport:missing")
|
||||||
|
|
||||||
def test_good_load_internal(self):
|
def test_good_load_internal(self):
|
||||||
self.assertEquals(dummy_function,
|
self.assertEqual(dummy_function,
|
||||||
simport.load("test_simport:dummy_function"))
|
simport.load("test_simport:dummy_function"))
|
||||||
self.assertEquals(DummyClass.method_a,
|
self.assertEqual(DummyClass.method_a,
|
||||||
simport.load("test_simport:DummyClass.method_a"))
|
simport.load("test_simport:DummyClass.method_a"))
|
||||||
|
|
||||||
def test_good_load_local(self):
|
def test_good_load_local(self):
|
||||||
method = simport.load("tests|"
|
method = simport.load("tests|"
|
||||||
"localmodule:Foo.method_a")
|
"localmodule:Foo.method_a")
|
||||||
import localmodule
|
import localmodule
|
||||||
self.assertEquals(method, localmodule.Foo.method_a)
|
|
||||||
self.assertEquals(localmodule.function_a,
|
self.assertEqual(method, localmodule.Foo.method_a)
|
||||||
simport.load("localmodule:function_a"))
|
self.assertEqual(localmodule.function_a,
|
||||||
|
simport.load("localmodule:function_a"))
|
||||||
|
|
||||||
def test_good_load_external(self):
|
def test_good_load_external(self):
|
||||||
method = simport.load("tests/external|"
|
method = simport.load("tests/external|"
|
||||||
@ -82,6 +98,7 @@ class TestSimport(unittest.TestCase):
|
|||||||
klass = simport.load("tests/external|"
|
klass = simport.load("tests/external|"
|
||||||
"external.externalmodule:Blah")
|
"external.externalmodule:Blah")
|
||||||
import external.externalmodule
|
import external.externalmodule
|
||||||
|
|
||||||
self.assertEqual(klass, external.externalmodule.Blah)
|
self.assertEqual(klass, external.externalmodule.Blah)
|
||||||
|
|
||||||
def test_local_class(self):
|
def test_local_class(self):
|
||||||
|
4
tox.ini
4
tox.ini
@ -3,12 +3,10 @@ envlist = py26,py27,pep8
|
|||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
deps =
|
deps =
|
||||||
|
-r{toxinidir}/requirements.txt
|
||||||
coverage
|
coverage
|
||||||
nose
|
nose
|
||||||
mock
|
mock
|
||||||
flake8
|
|
||||||
|
|
||||||
setenv = VIRTUAL_ENV={envdir}
|
|
||||||
|
|
||||||
commands = nosetests -d -v --with-coverage --cover-inclusive --cover-package simport []
|
commands = nosetests -d -v --with-coverage --cover-inclusive --cover-package simport []
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user