@@ -47,20 +47,18 @@ def test_contents(self):
47
47
test the ability of tables to self-populate using the contents property
48
48
"""
49
49
# test contents
50
- assert_true ( self .user )
51
- assert_true ( len (self .user ) == len (self .user .contents ) )
50
+ assert self .user
51
+ assert len (self .user ) == len (self .user .contents )
52
52
u = self .user .fetch (order_by = ["username" ])
53
- assert_list_equal (
54
- list (u ["username" ]), sorted ([s [0 ] for s in self .user .contents ])
55
- )
53
+ assert (
54
+ list (u ["username" ]) == sorted ([s [0 ] for s in self .user .contents ]))
56
55
57
56
# test prepare
58
- assert_true ( self .subject )
59
- assert_true ( len (self .subject ) == len (self .subject .contents ) )
57
+ assert self .subject
58
+ assert len (self .subject ) == len (self .subject .contents )
60
59
u = self .subject .fetch (order_by = ["subject_id" ])
61
- assert_list_equal (
62
- list (u ["subject_id" ]), sorted ([s [0 ] for s in self .subject .contents ])
63
- )
60
+ assert (
61
+ list (u ["subject_id" ]) == sorted ([s [0 ] for s in self .subject .contents ]))
64
62
65
63
@raises (dj .DataJointError )
66
64
def test_misnamed_attribute1 (self ):
@@ -108,7 +106,7 @@ def test_wrong_insert_type(self):
108
106
def test_insert_select (self ):
109
107
schema .TTest2 .delete ()
110
108
schema .TTest2 .insert (schema .TTest )
111
- assert_equal ( len (schema .TTest2 ()), len (schema .TTest () ))
109
+ assert len (schema .TTest2 ()) == len (schema .TTest ())
112
110
113
111
original_length = len (self .subject )
114
112
elements = self .subject .proj (..., s = "subject_id" )
@@ -120,18 +118,18 @@ def test_insert_select(self):
120
118
species = '"human"' ,
121
119
)
122
120
self .subject .insert (elements , ignore_extra_fields = True )
123
- assert_equal ( len (self .subject ), 2 * original_length )
121
+ assert len (self .subject ) == 2 * original_length
124
122
125
123
def test_insert_pandas_roundtrip (self ):
126
124
"""ensure fetched frames can be inserted"""
127
125
schema .TTest2 .delete ()
128
126
n = len (schema .TTest ())
129
- assert_true ( n > 0 )
127
+ assert n > 0
130
128
df = schema .TTest .fetch (format = "frame" )
131
- assert_true ( isinstance (df , pandas .DataFrame ) )
132
- assert_equal ( len (df ), n )
129
+ assert isinstance (df , pandas .DataFrame )
130
+ assert len (df ) == n
133
131
schema .TTest2 .insert (df )
134
- assert_equal ( len (schema .TTest2 ()), n )
132
+ assert len (schema .TTest2 ()) == n
135
133
136
134
def test_insert_pandas_userframe (self ):
137
135
"""
@@ -140,12 +138,12 @@ def test_insert_pandas_userframe(self):
140
138
"""
141
139
schema .TTest2 .delete ()
142
140
n = len (schema .TTest ())
143
- assert_true ( n > 0 )
141
+ assert n > 0
144
142
df = pandas .DataFrame (schema .TTest .fetch ())
145
- assert_true ( isinstance (df , pandas .DataFrame ) )
146
- assert_equal ( len (df ), n )
143
+ assert isinstance (df , pandas .DataFrame )
144
+ assert len (df ) == n
147
145
schema .TTest2 .insert (df )
148
- assert_equal ( len (schema .TTest2 ()), n )
146
+ assert len (schema .TTest2 ()) == n
149
147
150
148
@raises (dj .DataJointError )
151
149
def test_insert_select_ignore_extra_fields0 (self ):
@@ -191,9 +189,8 @@ def test_replace(self):
191
189
key = dict (subject_id = 7 )
192
190
date = "2015-01-01"
193
191
self .subject .insert1 (dict (key , real_id = 7 , date_of_birth = date , subject_notes = "" ))
194
- assert_equal (
195
- date , str ((self .subject & key ).fetch1 ("date_of_birth" )), "incorrect insert"
196
- )
192
+ assert (
193
+ date == str ((self .subject & key ).fetch1 ("date_of_birth" ))), "incorrect insert"
197
194
date = "2015-01-02"
198
195
self .subject .insert1 (
199
196
dict (key , real_id = 7 , date_of_birth = date , subject_notes = "" ),
@@ -207,9 +204,8 @@ def test_replace(self):
207
204
self .subject .insert1 (
208
205
dict (key , real_id = 7 , date_of_birth = date , subject_notes = "" ), replace = True
209
206
)
210
- assert_equal (
211
- date , str ((self .subject & key ).fetch1 ("date_of_birth" )), "replace failed"
212
- )
207
+ assert (
208
+ date == str ((self .subject & key ).fetch1 ("date_of_birth" ))), "replace failed"
213
209
214
210
def test_delete_quick (self ):
215
211
"""Tests quick deletion"""
@@ -224,9 +220,9 @@ def test_delete_quick(self):
224
220
s = self .subject & (
225
221
"subject_id in (%s)" % "," .join (str (r ) for r in tmp ["subject_id" ])
226
222
)
227
- assert_true ( len (s ) == 2 , "insert did not work." )
223
+ assert len (s ) == 2 , "insert did not work."
228
224
s .delete_quick ()
229
- assert_true ( len (s ) == 0 , "delete did not work." )
225
+ assert len (s ) == 0 , "delete did not work."
230
226
231
227
def test_skip_duplicate (self ):
232
228
"""Tests if duplicates are properly skipped."""
@@ -270,7 +266,7 @@ def test_blob_insert(self):
270
266
X = np .random .randn (20 , 10 )
271
267
self .img .insert1 ((1 , X ))
272
268
Y = self .img .fetch ()[0 ]["img" ]
273
- assert_true ( np .all (X == Y ), "Inserted and retrieved image are not identical" )
269
+ assert np .all (X == Y ), "Inserted and retrieved image are not identical"
274
270
275
271
def test_drop (self ):
276
272
"""Tests dropping tables"""
@@ -305,7 +301,7 @@ def test_table_regexp(self):
305
301
def test_table_size (self ):
306
302
"""test getting the size of the table and its indices in bytes"""
307
303
number_of_bytes = self .experiment .size_on_disk
308
- assert_true ( isinstance (number_of_bytes , int ) and number_of_bytes > 100 )
304
+ assert isinstance (number_of_bytes , int ) and number_of_bytes > 100
309
305
310
306
def test_repr_html (self ):
311
- assert_true ( self .ephys ._repr_html_ ().strip ().startswith ("<style" ) )
307
+ assert self .ephys ._repr_html_ ().strip ().startswith ("<style" )
0 commit comments