From 462d7a3971ff1a964bf50a2795da27ba8953f9cd Mon Sep 17 00:00:00 2001 From: Adam Robbins-Pianka Date: Thu, 14 May 2015 17:00:31 -0600 Subject: [PATCH] TST: Fix warnings The message of the warning could also be checked, if desired, but previously it was not being checked explicitly. --- .../test/test_prep_template.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/qiita_db/metadata_template/test/test_prep_template.py b/qiita_db/metadata_template/test/test_prep_template.py index 7abafbba7..e2ea79608 100644 --- a/qiita_db/metadata_template/test/test_prep_template.py +++ b/qiita_db/metadata_template/test/test_prep_template.py @@ -12,6 +12,7 @@ from os import close, remove from os.path import join, basename from collections import Iterable +import warnings import numpy.testing as npt import pandas as pd @@ -1307,9 +1308,20 @@ def test_check_restrictions(self): self.assertEqual(obs, set()) del self.metadata['primer'] - pt = npt.assert_warns(QiitaDBWarning, PrepTemplate.create, - self.metadata, self.new_raw_data, - self.test_study, self.data_type) + + caught_QiitaDBWarning = False + + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") + pt = PrepTemplate.create(self.metadata, self.new_raw_data, + self.test_study, self.data_type) + + # There might be several warnings raised. Make sure one of them + # is a QiitaDBWarning + if any([_w.category == QiitaDBWarning for _w in w]): + caught_QiitaDBWarning = True + + self.assertTrue(caught_QiitaDBWarning) obs = pt.check_restrictions( [PREP_TEMPLATE_COLUMNS['EBI'],