From 17a0af34dac64c330089f1e3018ffa35eb33828f Mon Sep 17 00:00:00 2001 From: Richard Gildea Date: Wed, 22 Feb 2023 15:01:24 +0000 Subject: [PATCH] Ignore deprecated `pkg_resources.declare_namespace` warnings (#611) As of setuptools v67.3.0 the use of pkg_resources.declare_namespace in lib/mpl_toolkits/__init__.py raises a DeprecationWarning. See also: https://github.com/matplotlib/matplotlib/issues/25244 Run tests directly rather than as a subprocess so that pytest filterwarnings options have their intended effect. --- newsfragments/611.misc | 1 + pytest.ini | 1 + tests/command_line/test_print_header.py | 11 ++++++----- tests/command_line/test_show_mask_info.py | 12 ++++++------ 4 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 newsfragments/611.misc diff --git a/newsfragments/611.misc b/newsfragments/611.misc new file mode 100644 index 000000000..7044a3bdd --- /dev/null +++ b/newsfragments/611.misc @@ -0,0 +1 @@ +Ignore deprecated ``pkg_resources.declare_namespace`` warnings in pytest diff --git a/pytest.ini b/pytest.ini index d4352b407..a3adf716c 100644 --- a/pytest.ini +++ b/pytest.ini @@ -4,6 +4,7 @@ filterwarnings = ignore:the matrix subclass is not the recommended way:PendingDeprecationWarning ignore:numpy.dtype size changed:RuntimeWarning ignore:Datablocks are deprecated:UserWarning + ignore:Deprecated call to `pkg_resources.declare_namespace:DeprecationWarning junit_family = legacy markers = regression: dxtbx regression test diff --git a/tests/command_line/test_print_header.py b/tests/command_line/test_print_header.py index 04ba7affc..e4f1a7f95 100644 --- a/tests/command_line/test_print_header.py +++ b/tests/command_line/test_print_header.py @@ -1,18 +1,19 @@ from __future__ import annotations -import procrunner +from dxtbx.command_line import print_header -def test_print_header(dials_data): +def test_print_header(dials_data, capsys): screen = dials_data("thaumatin_eiger_screen", pathlib=True) master = screen / "Therm_6_1_master.h5" - result = procrunner.run(["dxtbx.print_header", master]) - assert not result.returncode and not result.stderr + print_header.run([str(master)]) expected_output = [ f"=== {master} ===", "Using header reader: FormatNXmxDLS16M", ] + captured = capsys.readouterr() + assert not captured.err for record in expected_output: - assert record.strip().encode("latin-1") in result.stdout, record + assert record.strip() in captured.out, record diff --git a/tests/command_line/test_show_mask_info.py b/tests/command_line/test_show_mask_info.py index 4adad867d..0df50d7c7 100644 --- a/tests/command_line/test_show_mask_info.py +++ b/tests/command_line/test_show_mask_info.py @@ -1,12 +1,12 @@ from __future__ import annotations -import procrunner +from dxtbx.command_line import show_mask_info -def test_show_mask_info(dials_data): +def test_show_mask_info(dials_data, capsys): data = dials_data("image_examples", pathlib=True) / "dectris_eiger_master.h5" - result = procrunner.run(["dxtbx.show_mask_info", data]) - assert not result.returncode and not result.stderr - - assert b"Module 0 has 637992 masked pixels of 10166590" in result.stdout + show_mask_info.run([str(data)]) + captured = capsys.readouterr() + assert not captured.err + assert "Module 0 has 637992 masked pixels of 10166590" in captured.out