1
- from nose . tools import assert_true , assert_equal , raises
1
+ import pytest
2
2
import uuid
3
3
from .schema_uuid import Basic , Item , Topic
4
4
from datajoint import DataJointError
5
5
from itertools import count
6
6
7
7
8
- def test_uuid ():
8
+ def test_uuid (schema_uuid ):
9
9
"""test inserting and fetching of UUID attributes and restricting by UUID attributes"""
10
10
u , n = uuid .uuid4 (), - 1
11
11
Basic ().insert1 (dict (item = u , number = n ))
@@ -16,7 +16,7 @@ def test_uuid():
16
16
assert u == item
17
17
18
18
19
- def test_string_uuid ():
19
+ def test_string_uuid (schema_uuid ):
20
20
"""test that only UUID objects are accepted when inserting UUID fields"""
21
21
u , n = "00000000-0000-0000-0000-000000000000" , 24601
22
22
Basic ().insert1 (dict (item = u , number = n ))
@@ -25,35 +25,35 @@ def test_string_uuid():
25
25
assert isinstance (k ["item" ], uuid .UUID )
26
26
27
27
28
- @raises (DataJointError )
29
- def test_invalid_uuid_insert1 ():
28
+ def test_invalid_uuid_insert1 (schema_uuid ):
30
29
"""test that only UUID objects are accepted when inserting UUID fields"""
31
30
u , n = 0 , 24601
32
- Basic ().insert1 (dict (item = u , number = n ))
31
+ with pytest .raises (DataJointError ):
32
+ Basic ().insert1 (dict (item = u , number = n ))
33
33
34
34
35
- @raises (DataJointError )
36
- def test_invalid_uuid_insert2 ():
35
+ def test_invalid_uuid_insert2 (schema_uuid ):
37
36
"""test that only UUID objects are accepted when inserting UUID fields"""
38
37
u , n = "abc" , 24601
39
- Basic ().insert1 (dict (item = u , number = n ))
38
+ with pytest .raises (DataJointError ):
39
+ Basic ().insert1 (dict (item = u , number = n ))
40
40
41
41
42
- @raises (DataJointError )
43
- def test_invalid_uuid_restrict1 ():
42
+ def test_invalid_uuid_restrict1 (schema_uuid ):
44
43
"""test that only UUID objects are accepted when inserting UUID fields"""
45
44
u = 0
46
- k , m = (Basic & {"item" : u }).fetch1 ("KEY" , "number" )
45
+ with pytest .raises (DataJointError ):
46
+ k , m = (Basic & {"item" : u }).fetch1 ("KEY" , "number" )
47
47
48
48
49
- @raises (DataJointError )
50
- def test_invalid_uuid_restrict1 ():
49
+ def test_invalid_uuid_restrict1 (schema_uuid ):
51
50
"""test that only UUID objects are accepted when inserting UUID fields"""
52
51
u = "abc"
53
- k , m = (Basic & {"item" : u }).fetch1 ("KEY" , "number" )
52
+ with pytest .raises (DataJointError ):
53
+ k , m = (Basic & {"item" : u }).fetch1 ("KEY" , "number" )
54
54
55
55
56
- def test_uuid_dependencies ():
56
+ def test_uuid_dependencies (schema_uuid ):
57
57
"""test the use of UUID in foreign keys"""
58
58
for word in (
59
59
"Neuroscience" ,
0 commit comments