cleanup/pep8

This commit is contained in:
Martin Baeuml
2014-03-19 22:35:42 +01:00
parent 957daf4c84
commit db1dc22036
7 changed files with 48 additions and 48 deletions
+4 -13
View File
@@ -6,17 +6,8 @@ class MockupContainer:
def someFileAnnotations(i):
annotations = []
annotations.append({'type': 'rect',
'x': 10 * i,
'y': '20',
'w': '40',
'h': '60'})
annotations.append({'type': 'rect',
'x': '80',
'y': 20 * i,
'w': '40',
'h': '60'})
annotations = [{'type': 'rect', 'x': 10 * i, 'y': '20', 'w': '40', 'h': '60'},
{'type': 'rect', 'x': '80', 'y': 20 * i, 'w': '40', 'h': '60'}]
for k in range(i):
annotations.append({'type': 'point',
'x': 30 * k,
@@ -27,12 +18,12 @@ def someFileAnnotations(i):
def someAnnotations():
annotations = []
for i in range(5):
file = {
ann = {
'filename': 'file%d.png' % i,
'type': 'image',
'annotations': someFileAnnotations(i)
}
annotations.append(file)
annotations.append(ann)
return annotations
+17 -5
View File
@@ -1,9 +1,18 @@
import pytest
from sloth.items import Factory
class MockupRectItem: pass
class MockupPointItem: pass
class MockupPolygonItem: pass
class MockupRectItem:
pass
class MockupPointItem:
pass
class MockupPolygonItem:
pass
def _create_factory():
itemfactory = Factory({'point': MockupPointItem,
@@ -12,6 +21,7 @@ def _create_factory():
return itemfactory
def test_register():
itemfactory = _create_factory()
@@ -24,11 +34,13 @@ def test_register():
item = itemfactory.create('polygon2')
assert item is None
def test_register_fail():
itemfactory = _create_factory()
with pytest.raises(Exception):
itemfactory.register('rect', MockupRectItem)
def test_register_replace():
itemfactory = _create_factory()
@@ -36,6 +48,7 @@ def test_register_replace():
item = itemfactory.create('rect')
assert isinstance(item, MockupPolygonItem)
def test_clear():
itemfactory = _create_factory()
@@ -51,5 +64,4 @@ def test_clear():
assert isinstance(item, MockupPolygonItem)
itemfactory.clear()
assert itemfactory.create('point') is None
assert itemfactory.create('polygon') is None
assert itemfactory.create('polygon') is None