forked from luxonis/depthai-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdai_path_conversion_test.py
More file actions
47 lines (32 loc) · 1.22 KB
/
dai_path_conversion_test.py
File metadata and controls
47 lines (32 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# -*- coding: utf-8 -*-
import sys
import pytest
import depthai as dai
from pathlib import Path
def test_dai_path_conversion_positive():
# Can raise RuntimeError but not TypeError (eg if string/Path weren't accepted as parameters)
with pytest.raises(Exception) as excinfo:
a = dai.AssetManager()
nn = dai.Pipeline().create(dai.node.NeuralNetwork)
string_path = 'test.txt'
pathlib_path = Path('pathlib.txt')
# AssetManager
a.set('p1', string_path)
a.set('p2', pathlib_path)
# NN
nn.setBlobPath('p1', string_path)
nn.setBlobPath('p2', pathlib_path)
nn.setBlob('p1', string_path)
nn.setBlob('p2', pathlib_path)
assert(excinfo is not RuntimeError)
def test_dai_path_conversion_negative():
# Must raise TypeError, to indicate that given argument wasn't converted to Path
a = dai.AssetManager()
nn = dai.Pipeline().create(dai.node.NeuralNetwork)
info = dai.DeviceInfo() # str representable
with pytest.raises(TypeError) as excinfo:
a.set('invalid', info)
with pytest.raises(TypeError) as excinfo:
nn.setBlobPath(info)
with pytest.raises(TypeError) as excinfo:
nn.setBlob(info)