From 1c5c80fb53075706ba74751468d748960fae9dd9 Mon Sep 17 00:00:00 2001 From: Hind-M Date: Tue, 2 Aug 2022 14:56:51 +0200 Subject: Pull out the for loop in test --- src/python/test/test_dtm.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/python/test/test_dtm.py') diff --git a/src/python/test/test_dtm.py b/src/python/test/test_dtm.py index 21cff055..b276f041 100755 --- a/src/python/test/test_dtm.py +++ b/src/python/test/test_dtm.py @@ -92,11 +92,10 @@ def test_density(): def test_dtm_overflow_warnings(): pts = numpy.array([[10., 100000000000000000000000000000.], [1000., 100000000000000000000000000.]]) impl_warn = ["keops", "hnsw"] - with warnings.catch_warnings(record=True) as w: - for impl in impl_warn: + for impl in impl_warn: + with warnings.catch_warnings(record=True) as w: dtm = DistanceToMeasure(2, implementation=impl) r = dtm.fit_transform(pts) - assert len(w) == 2 - for i in range(len(w)): - assert issubclass(w[i].category, RuntimeWarning) - assert "Overflow" in str(w[i].message) + assert len(w) == 1 + assert issubclass(w[0].category, RuntimeWarning) + assert "Overflow" in str(w[0].message) -- cgit v1.2.3