From cd16368e11c7fb265d38f72d019261cb39a65fd3 Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Tue, 27 Jun 2023 17:13:44 -0400 Subject: [PATCH] TST: Fix bz2 non-import test --- pandas/tests/test_common.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pandas/tests/test_common.py b/pandas/tests/test_common.py index 6753008851338..dc7f0578b41aa 100644 --- a/pandas/tests/test_common.py +++ b/pandas/tests/test_common.py @@ -250,10 +250,11 @@ def test_str_size(): def test_bz2_missing_import(): # Check whether bz2 missing import is handled correctly (issue #53857) code = ( + "import sys\n" + "assert 'bz2' in sys.modules\n" + "sys.modules['bz2'] = None\n" "import pytest\n" - "sys.modules.pop('bz2', None)\n" - "import pandas\n" - "assert 'bz2' not in sys.modules\n" + "import pandas as pd\n" "from pandas.compat import get_bz2_file\n" "msg = 'bz2 module not available.'\n" "with pytest.raises(RuntimeError, match=msg):\n"