mirror of
https://github.com/wassname/sloth.git
synced 2026-08-12 12:30:50 +08:00
cleanup/pep8
This commit is contained in:
+4
-13
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user