Skip to content

Commit 3998cb4

Browse files
committed
Use fixture for TTest2
1 parent 34ddf0d commit 3998cb4

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

tests/test_relation.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ def test(schema_any):
1515
yield schema.TTest()
1616

1717

18+
@pytest.fixture
19+
def test2(schema_any):
20+
yield schema.TTest2()
21+
22+
1823
@pytest.fixture
1924
def test_extra(schema_any):
2025
yield schema.TTestExtra()
@@ -123,10 +128,10 @@ def test_wrong_insert_type(user):
123128
user.insert1(3)
124129

125130

126-
def test_insert_select(subject):
127-
schema.TTest2.delete()
128-
schema.TTest2.insert(schema.TTest)
129-
assert len(schema.TTest2()) == len(schema.TTest())
131+
def test_insert_select(subject, test2):
132+
test2.delete()
133+
test2.insert(schema.TTest)
134+
assert len(test2) == len(schema.TTest())
130135

131136
original_length = len(subject)
132137
elements = subject.proj(..., s="subject_id")
@@ -141,31 +146,31 @@ def test_insert_select(subject):
141146
assert len(subject) == 2 * original_length
142147

143148

144-
def test_insert_pandas_roundtrip(schema_any):
149+
def test_insert_pandas_roundtrip(test2):
145150
"""ensure fetched frames can be inserted"""
146-
schema.TTest2.delete()
151+
test2.delete()
147152
n = len(schema.TTest())
148153
assert n > 0
149154
df = schema.TTest.fetch(format="frame")
150155
assert isinstance(df, pandas.DataFrame)
151156
assert len(df) == n
152-
schema.TTest2.insert(df)
153-
assert len(schema.TTest2()) == n
157+
test2.insert(df)
158+
assert len(test2) == n
154159

155160

156-
def test_insert_pandas_userframe(schema_any):
161+
def test_insert_pandas_userframe(test2):
157162
"""
158163
ensure simple user-created frames (1 field, non-custom index)
159164
can be inserted without extra index adjustment
160165
"""
161-
schema.TTest2.delete()
166+
test2.delete()
162167
n = len(schema.TTest())
163168
assert n > 0
164169
df = pandas.DataFrame(schema.TTest.fetch())
165170
assert isinstance(df, pandas.DataFrame)
166171
assert len(df) == n
167-
schema.TTest2.insert(df)
168-
assert len(schema.TTest2()) == n
172+
test2.insert(df)
173+
assert len(test2) == n
169174

170175

171176
def test_insert_select_ignore_extra_fields0(test, test_extra):

0 commit comments

Comments
 (0)