|
1 | | -import contextlib |
2 | 1 | from datetime import datetime, time |
3 | 2 | from functools import partial |
4 | 3 | import os |
5 | 4 | from urllib.error import URLError |
6 | | -import warnings |
7 | 5 |
|
8 | 6 | import numpy as np |
9 | 7 | import pytest |
|
14 | 12 | from pandas import DataFrame, Index, MultiIndex, Series |
15 | 13 | import pandas._testing as tm |
16 | 14 |
|
17 | | - |
18 | | -@contextlib.contextmanager |
19 | | -def ignore_xlrd_time_clock_warning(): |
20 | | - """ |
21 | | - Context manager to ignore warnings raised by the xlrd library, |
22 | | - regarding the deprecation of `time.clock` in Python 3.7. |
23 | | - """ |
24 | | - with warnings.catch_warnings(): |
25 | | - warnings.filterwarnings( |
26 | | - action="ignore", |
27 | | - message="time.clock has been deprecated", |
28 | | - category=DeprecationWarning, |
29 | | - ) |
30 | | - yield |
31 | | - |
32 | | - |
33 | 15 | read_ext_params = [".xls", ".xlsx", ".xlsm", ".xlsb", ".ods"] |
34 | 16 | engine_params = [ |
35 | 17 | # Add any engines to test here |
@@ -134,21 +116,19 @@ def test_usecols_int(self, read_ext, df_ref): |
134 | 116 | # usecols as int |
135 | 117 | msg = "Passing an integer for `usecols`" |
136 | 118 | with pytest.raises(ValueError, match=msg): |
137 | | - with ignore_xlrd_time_clock_warning(): |
138 | | - pd.read_excel( |
139 | | - "test1" + read_ext, sheet_name="Sheet1", index_col=0, usecols=3 |
140 | | - ) |
| 119 | + pd.read_excel( |
| 120 | + "test1" + read_ext, sheet_name="Sheet1", index_col=0, usecols=3 |
| 121 | + ) |
141 | 122 |
|
142 | 123 | # usecols as int |
143 | 124 | with pytest.raises(ValueError, match=msg): |
144 | | - with ignore_xlrd_time_clock_warning(): |
145 | | - pd.read_excel( |
146 | | - "test1" + read_ext, |
147 | | - sheet_name="Sheet2", |
148 | | - skiprows=[1], |
149 | | - index_col=0, |
150 | | - usecols=3, |
151 | | - ) |
| 125 | + pd.read_excel( |
| 126 | + "test1" + read_ext, |
| 127 | + sheet_name="Sheet2", |
| 128 | + skiprows=[1], |
| 129 | + index_col=0, |
| 130 | + usecols=3, |
| 131 | + ) |
152 | 132 |
|
153 | 133 | def test_usecols_list(self, read_ext, df_ref): |
154 | 134 | if pd.read_excel.keywords["engine"] == "pyxlsb": |
@@ -597,8 +577,7 @@ def test_sheet_name(self, read_ext, df_ref): |
597 | 577 | df1 = pd.read_excel( |
598 | 578 | filename + read_ext, sheet_name=sheet_name, index_col=0 |
599 | 579 | ) # doc |
600 | | - with ignore_xlrd_time_clock_warning(): |
601 | | - df2 = pd.read_excel(filename + read_ext, index_col=0, sheet_name=sheet_name) |
| 580 | + df2 = pd.read_excel(filename + read_ext, index_col=0, sheet_name=sheet_name) |
602 | 581 |
|
603 | 582 | tm.assert_frame_equal(df1, df_ref, check_names=False) |
604 | 583 | tm.assert_frame_equal(df2, df_ref, check_names=False) |
|
0 commit comments