Skip to content

Commit 74fc4d9

Browse files
authored
Test speedups (#155)
Examples already tested in test_examples.py and two abc2 calls -> one abc2 call
1 parent 65567eb commit 74fc4d9

File tree

2 files changed

+14
-21
lines changed

2 files changed

+14
-21
lines changed

q2_composition/tests/test_ancombc.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ def setUp(self):
3232

3333

3434
class TestANCOMBC(TestBase):
35-
def test_examples(self):
36-
self.execute_examples()
37-
3835
# error handling for column validation
3936
def test_missing_formula_col(self):
4037
with self.assertRaisesRegex(ValueError, "'foo' is not a column in"

q2_composition/tests/test_ancombc2.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ def setUpClass(cls):
4141

4242

4343
class TestANCOMBC2(TestANCOMBC2Base):
44+
@classmethod
45+
def setUpClass(cls):
46+
super().setUpClass()
47+
48+
cls.abc2_output = ancombc2(
49+
table=cls.biom_table,
50+
metadata=cls.metadata,
51+
fixed_effects_formula='body-site + year',
52+
group='body-site',
53+
structural_zeros=True
54+
)
55+
4456
def _slices_to_single_df(
4557
self, slices: ANCOMBC2SliceMapping
4658
) -> pd.DataFrame:
@@ -149,16 +161,8 @@ def test_ancombc2_visualizer(self):
149161
test of whether or not the visualizer got built into the
150162
q2_composition/_ancombc2_visualizer/dist/ folder successfully.
151163
'''
152-
abc2_output = ancombc2(
153-
table=self.biom_table,
154-
metadata=self.metadata,
155-
fixed_effects_formula='body-site + year',
156-
group='body-site',
157-
structural_zeros=True
158-
)
159-
160164
with tempfile.TemporaryDirectory() as tempdir:
161-
ancombc2_visualizer(tempdir, abc2_output)
165+
ancombc2_visualizer(tempdir, self.abc2_output)
162166
assert os.path.exists(os.path.join(tempdir, 'index.html'))
163167

164168
def test_ancombc2_visualizer_non_overlapping_taxonomy(self):
@@ -167,14 +171,6 @@ def test_ancombc2_visualizer_non_overlapping_taxonomy(self):
167171
data with a taxonomy that contains none of the features present in the
168172
ancombc2 data.
169173
'''
170-
abc2_output = ancombc2(
171-
table=self.biom_table,
172-
metadata=self.metadata,
173-
fixed_effects_formula='body-site + year',
174-
group='body-site',
175-
structural_zeros=True
176-
)
177-
178174
taxonomy_df = pd.DataFrame({
179175
'Feature ID': ['feat1', 'feat2'],
180176
'Taxon': ['taxon1', 'taxon2'],
@@ -185,7 +181,7 @@ def test_ancombc2_visualizer_non_overlapping_taxonomy(self):
185181
with self.assertRaisesRegex(
186182
ValueError, 'No features remained in your taxonomy'
187183
):
188-
ancombc2_visualizer(tempdir, abc2_output, taxonomy_df)
184+
ancombc2_visualizer(tempdir, self.abc2_output, taxonomy_df)
189185

190186

191187
class TestFormulaProcessing(TestANCOMBC2Base):

0 commit comments

Comments
 (0)