From 753f90560660d4f24313cd2335297ab4b0ee2b29 Mon Sep 17 00:00:00 2001 From: Paola Ferrario Date: Tue, 4 Jun 2024 14:34:11 +0200 Subject: [PATCH] Fix test to check that output file does not exist --- invisible_cities/cities/buffy_test.py | 9 +++------ invisible_cities/cities/components.py | 2 ++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/invisible_cities/cities/buffy_test.py b/invisible_cities/cities/buffy_test.py index c369e3ba9..ee14c3293 100644 --- a/invisible_cities/cities/buffy_test.py +++ b/invisible_cities/cities/buffy_test.py @@ -86,13 +86,10 @@ def test_buffy_no_file_without_sns_response(config_tmpdir, ICDATADIR): conf = configure('buffy invisible_cities/config/buffy.conf'.split()) conf.update(dict(files_in=file_in, file_out=file_out, event_range=nevt)) - try: + with warnings.catch_warnings(): + warnings.simplefilter("ignore", category=UserWarning) buffy(**conf) - except: - if not os.path.exists(file_out): - assert True - else: - assert False + assert not os.path.exists(file_out) def test_buffy_filters_empty(config_tmpdir, ICDATADIR): diff --git a/invisible_cities/cities/components.py b/invisible_cities/cities/components.py index fd89e4da0..872df6ed1 100644 --- a/invisible_cities/cities/components.py +++ b/invisible_cities/cities/components.py @@ -179,6 +179,8 @@ def index_tables(file_out): -checks if any columns in the tables have been marked to be indexed by writers -indexes those columns """ + if not os.path.exists(file_out): + return with tb.open_file(file_out, 'r+') as h5out: for table in h5out.walk_nodes(classname='Table'): # Walk over all tables in h5out if 'columns_to_index' not in table.attrs: continue # Check for columns to index