From 28cd2e9621bfe6fb67b176d4df1c4a720a43fc13 Mon Sep 17 00:00:00 2001 From: Padraic Shafer Date: Wed, 25 Oct 2023 12:07:39 -0700 Subject: [PATCH 1/8] Assert nan/inf data in test_nan_infinity_handler() --- tiled/_tests/test_array.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tiled/_tests/test_array.py b/tiled/_tests/test_array.py index 9f44f0da0..8bcbf66e6 100644 --- a/tiled/_tests/test_array.py +++ b/tiled/_tests/test_array.py @@ -108,8 +108,12 @@ def test_shape_with_zero(context): def test_nan_infinity_handler(tmpdir, context): client = from_context(context)["inf"] - print(f"Metadata: {client['example'].metadata}") - print(f"Data: {client['example'].read()}") + data = client['example'].read() + assert numpy.isnan(data).any() + assert numpy.isinf(data).any() + metadata = tuple(client['example'].metadata.values()) + assert numpy.isnan(metadata).any() + assert numpy.isinf(metadata).any() Path(tmpdir, "testjson").mkdir() client["example"].export(Path(tmpdir, "testjson", "test.json")) From 1d758a170c0fad0a2b490d10e5dbe2b908f0d8e0 Mon Sep 17 00:00:00 2001 From: Padraic Shafer Date: Wed, 25 Oct 2023 12:11:33 -0700 Subject: [PATCH 2/8] Assert dtype of vlen_str_in_dataset --- tiled/_tests/test_hdf5.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tiled/_tests/test_hdf5.py b/tiled/_tests/test_hdf5.py index d662c20ff..ff6c0f66c 100644 --- a/tiled/_tests/test_hdf5.py +++ b/tiled/_tests/test_hdf5.py @@ -32,7 +32,7 @@ def example_file_with_vlen_str_in_dataset(): # Need to do this to make a vlen str dataset dt = h5py.string_dtype(encoding="utf-8") dset = c.create_dataset("d", (100,), dtype=dt) - # print(dset.dtype) + assert dset.dtype == "object" dset[0] = b"test" return file From adff2737bdf488f59fe11b1a660d172b248dde6b Mon Sep 17 00:00:00 2001 From: Padraic Shafer Date: Wed, 25 Oct 2023 12:12:37 -0700 Subject: [PATCH 3/8] Remove debug print() from TIFF adapter --- tiled/adapters/tiff.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tiled/adapters/tiff.py b/tiled/adapters/tiff.py index 2365fac6f..f78e8a2da 100644 --- a/tiled/adapters/tiff.py +++ b/tiled/adapters/tiff.py @@ -144,7 +144,6 @@ def read(self, slice=None): of a group of images """ - # Print("Inside Adapter:", slice) if slice is None: return with_object_cache(self._cache_key, self._seq.asarray) if isinstance(slice, int): From 4d65054db1b74b4346f0382d66f1fa29f1ffeea6 Mon Sep 17 00:00:00 2001 From: Padraic Shafer Date: Wed, 25 Oct 2023 12:36:33 -0700 Subject: [PATCH 4/8] Black: consistent quotes --- tiled/_tests/test_array.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tiled/_tests/test_array.py b/tiled/_tests/test_array.py index 8bcbf66e6..e2acd556b 100644 --- a/tiled/_tests/test_array.py +++ b/tiled/_tests/test_array.py @@ -108,10 +108,10 @@ def test_shape_with_zero(context): def test_nan_infinity_handler(tmpdir, context): client = from_context(context)["inf"] - data = client['example'].read() + data = client["example"].read() assert numpy.isnan(data).any() assert numpy.isinf(data).any() - metadata = tuple(client['example'].metadata.values()) + metadata = tuple(client["example"].metadata.values()) assert numpy.isnan(metadata).any() assert numpy.isinf(metadata).any() Path(tmpdir, "testjson").mkdir() From 73c056eeee5e8505911d18ee0a606a8dde9dfe9a Mon Sep 17 00:00:00 2001 From: Padraic Shafer Date: Wed, 25 Oct 2023 12:37:46 -0700 Subject: [PATCH 5/8] Log thread count in tests --- pytest.ini | 4 ++++ tiled/_tests/conftest.py | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pytest.ini b/pytest.ini index 1f7ce09fc..41d0b1bc2 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,3 +1,7 @@ [pytest] testpaths = tiled/_tests +log_cli = 1 +log_cli_level = INFO +log_cli_format = %(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s) +log_cli_date_format=%Y-%m-%d %H:%M:%S diff --git a/tiled/_tests/conftest.py b/tiled/_tests/conftest.py index 341368bc8..3b771ddfb 100644 --- a/tiled/_tests/conftest.py +++ b/tiled/_tests/conftest.py @@ -80,13 +80,15 @@ def tmpdir_module(request, tmpdir_factory): # Use this with pytest -s option. if os.getenv("TILED_DEBUG_LEAKED_THREADS"): + import logging import threading import time def poll_enumerate(): + logger = logging.getLogger(__name__) while True: time.sleep(1) - print("THREAD COUNT", len(threading.enumerate())) + logger.info("THREAD COUNT = %d", len(threading.enumerate())) thread = threading.Thread(target=poll_enumerate, daemon=True) thread.start() From 98b72cc939a87fafc49f8dff1fed5141dc2aa583 Mon Sep 17 00:00:00 2001 From: Padraic Shafer Date: Wed, 25 Oct 2023 12:41:12 -0700 Subject: [PATCH 6/8] Less verbose logging by default --- pytest.ini | 2 +- tiled/_tests/conftest.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pytest.ini b/pytest.ini index 41d0b1bc2..18a858942 100644 --- a/pytest.ini +++ b/pytest.ini @@ -2,6 +2,6 @@ testpaths = tiled/_tests log_cli = 1 -log_cli_level = INFO +log_cli_level = WARNING log_cli_format = %(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s) log_cli_date_format=%Y-%m-%d %H:%M:%S diff --git a/tiled/_tests/conftest.py b/tiled/_tests/conftest.py index 3b771ddfb..7bc76f147 100644 --- a/tiled/_tests/conftest.py +++ b/tiled/_tests/conftest.py @@ -78,7 +78,7 @@ def tmpdir_module(request, tmpdir_factory): return tmpdir_factory.mktemp(request.module.__name__) -# Use this with pytest -s option. +# Use this with pytest --log-cli-level=INFO option. if os.getenv("TILED_DEBUG_LEAKED_THREADS"): import logging import threading From ed3f5613e38c741f352c829be0971a4f039b4a11 Mon Sep 17 00:00:00 2001 From: Padraic Shafer Date: Wed, 25 Oct 2023 12:47:59 -0700 Subject: [PATCH 7/8] Custom log level for TILED_DEBUG_LEAKED_THREADS --- tiled/_tests/conftest.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tiled/_tests/conftest.py b/tiled/_tests/conftest.py index 7bc76f147..e684ccb41 100644 --- a/tiled/_tests/conftest.py +++ b/tiled/_tests/conftest.py @@ -78,7 +78,7 @@ def tmpdir_module(request, tmpdir_factory): return tmpdir_factory.mktemp(request.module.__name__) -# Use this with pytest --log-cli-level=INFO option. +# Use this with pytest --log-cli-level=25 option. if os.getenv("TILED_DEBUG_LEAKED_THREADS"): import logging import threading @@ -86,9 +86,10 @@ def tmpdir_module(request, tmpdir_factory): def poll_enumerate(): logger = logging.getLogger(__name__) + msg_level = int(logging.INFO + logging.WARNING)//2 while True: time.sleep(1) - logger.info("THREAD COUNT = %d", len(threading.enumerate())) + logger.log(msg_level, "THREAD COUNT = %d", len(threading.enumerate())) thread = threading.Thread(target=poll_enumerate, daemon=True) thread.start() From 4689af142c080d02d2a0f3ecd6002faf26109206 Mon Sep 17 00:00:00 2001 From: Padraic Shafer <76011594+padraic-shafer@users.noreply.github.com> Date: Wed, 25 Oct 2023 13:14:45 -0700 Subject: [PATCH 8/8] Black: space around operator --- tiled/_tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tiled/_tests/conftest.py b/tiled/_tests/conftest.py index e684ccb41..f9aa778d2 100644 --- a/tiled/_tests/conftest.py +++ b/tiled/_tests/conftest.py @@ -86,7 +86,7 @@ def tmpdir_module(request, tmpdir_factory): def poll_enumerate(): logger = logging.getLogger(__name__) - msg_level = int(logging.INFO + logging.WARNING)//2 + msg_level = int(logging.INFO + logging.WARNING) // 2 while True: time.sleep(1) logger.log(msg_level, "THREAD COUNT = %d", len(threading.enumerate()))