Skip to content

Commit

Permalink
Organize the test code.
Browse files Browse the repository at this point in the history
  • Loading branch information
qiuwch committed May 26, 2017
1 parent b01ac25 commit e5ab172
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
2 changes: 2 additions & 0 deletions test/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ The test utilize docker to run test automatically. The test script will start a

The test scripts should be ended by a suffix '_test.py'

Run :code:`simple_test.py` to make the downloaded binary can work correctly.

1. Install dependencies first

:code:`pip install -r requirements.txt`
Expand Down
16 changes: 16 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,19 @@ def iserror(res):

def isok(res):
return res == 'ok'

class Version:
'''
Represent the version information, can be used for comparison
'''
def __init__(self, data):
if isinstance(data, str):
# parse vx.y.z
[self.x, self.y, self.z] = [int(v) for v in data.lstrip('v').split('.')]

def __cmp__(self, v):
if self.x != v.x:
return cmp(self.x, v.x)
if self.y != v.y:
return cmp(self.y, v.y)
return cmp(self.z, v.z)
14 changes: 14 additions & 0 deletions test/simple_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

from unrealcv import client
from conftest import env

def test_gt(env):
client.connect()
gt_types = ['lit', 'depth', 'normal', 'object_mask']
for v in gt_types:
res = client.request('vget /camera/0/{type} output/{type}.png'.format(type=v))
print(res)
im = cv2.imread(res)
print(im.shape)

# Make sure the dimension is right
15 changes: 1 addition & 14 deletions test/stereo_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pytest -s stereo.py -k [name]
from unrealcv import client
import math, random
from common import iserror, isok
from conftest import iserror, isok, Version

def get_version():
res = client.request('vget /unrealcv/version')
Expand All @@ -10,19 +10,6 @@ def get_version():
else:
return res

class Version:
def __init__(self, data):
if isinstance(data, str):
# parse vx.y.z
[self.x, self.y, self.z] = [int(v) for v in data.lstrip('v').split('.')]

def __cmp__(self, v):
if self.x != v.x:
return cmp(self.x, v.x)
if self.y != v.y:
return cmp(self.y, v.y)
return cmp(self.z, v.z)

class Vec3:
def __init__(self, data):
if isinstance(data, str):
Expand Down

0 comments on commit e5ab172

Please sign in to comment.