Skip to content

Commit 24e14ab

Browse files
committed
nose2pytest test_reconnection
1 parent 37b8fb3 commit 24e14ab

File tree

1 file changed

+27
-31
lines changed

1 file changed

+27
-31
lines changed

tests/test_relation.py

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,18 @@ def test_contents(self):
4747
test the ability of tables to self-populate using the contents property
4848
"""
4949
# 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)
5252
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]))
5655

5756
# 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)
6059
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]))
6462

6563
@raises(dj.DataJointError)
6664
def test_misnamed_attribute1(self):
@@ -108,7 +106,7 @@ def test_wrong_insert_type(self):
108106
def test_insert_select(self):
109107
schema.TTest2.delete()
110108
schema.TTest2.insert(schema.TTest)
111-
assert_equal(len(schema.TTest2()), len(schema.TTest()))
109+
assert len(schema.TTest2()) == len(schema.TTest())
112110

113111
original_length = len(self.subject)
114112
elements = self.subject.proj(..., s="subject_id")
@@ -120,18 +118,18 @@ def test_insert_select(self):
120118
species='"human"',
121119
)
122120
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
124122

125123
def test_insert_pandas_roundtrip(self):
126124
"""ensure fetched frames can be inserted"""
127125
schema.TTest2.delete()
128126
n = len(schema.TTest())
129-
assert_true(n > 0)
127+
assert n > 0
130128
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
133131
schema.TTest2.insert(df)
134-
assert_equal(len(schema.TTest2()), n)
132+
assert len(schema.TTest2()) == n
135133

136134
def test_insert_pandas_userframe(self):
137135
"""
@@ -140,12 +138,12 @@ def test_insert_pandas_userframe(self):
140138
"""
141139
schema.TTest2.delete()
142140
n = len(schema.TTest())
143-
assert_true(n > 0)
141+
assert n > 0
144142
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
147145
schema.TTest2.insert(df)
148-
assert_equal(len(schema.TTest2()), n)
146+
assert len(schema.TTest2()) == n
149147

150148
@raises(dj.DataJointError)
151149
def test_insert_select_ignore_extra_fields0(self):
@@ -191,9 +189,8 @@ def test_replace(self):
191189
key = dict(subject_id=7)
192190
date = "2015-01-01"
193191
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"
197194
date = "2015-01-02"
198195
self.subject.insert1(
199196
dict(key, real_id=7, date_of_birth=date, subject_notes=""),
@@ -207,9 +204,8 @@ def test_replace(self):
207204
self.subject.insert1(
208205
dict(key, real_id=7, date_of_birth=date, subject_notes=""), replace=True
209206
)
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"
213209

214210
def test_delete_quick(self):
215211
"""Tests quick deletion"""
@@ -224,9 +220,9 @@ def test_delete_quick(self):
224220
s = self.subject & (
225221
"subject_id in (%s)" % ",".join(str(r) for r in tmp["subject_id"])
226222
)
227-
assert_true(len(s) == 2, "insert did not work.")
223+
assert len(s) == 2, "insert did not work."
228224
s.delete_quick()
229-
assert_true(len(s) == 0, "delete did not work.")
225+
assert len(s) == 0, "delete did not work."
230226

231227
def test_skip_duplicate(self):
232228
"""Tests if duplicates are properly skipped."""
@@ -270,7 +266,7 @@ def test_blob_insert(self):
270266
X = np.random.randn(20, 10)
271267
self.img.insert1((1, X))
272268
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"
274270

275271
def test_drop(self):
276272
"""Tests dropping tables"""
@@ -305,7 +301,7 @@ def test_table_regexp(self):
305301
def test_table_size(self):
306302
"""test getting the size of the table and its indices in bytes"""
307303
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
309305

310306
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

Comments
 (0)