Skip to content

Commit 4e99eb7

Browse files
author
victor
committed
Useing null context managers from contextlib.
1 parent eaa1413 commit 4e99eb7

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

pandas/tests/scalar/timedelta/test_construction.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
import pandas.util.testing as tm
99
from pandas import Timedelta
1010

11+
import sys
12+
if sys.version_info >= (3, 3):
13+
from contextlib import ExitStack as do_not_raise
14+
else:
15+
from contextlib2 import ExitStack as do_not_raise
16+
1117

1218
def test_construction():
1319
expected = np.timedelta64(10, 'D').astype('m8[ns]').view('i8')
@@ -212,16 +218,8 @@ def test_td_constructor_value_error():
212218
Timedelta(nanoseconds='abc')
213219

214220

215-
class not_raises(object):
216-
def __enter__(self):
217-
pass
218-
219-
def __exit__(self, exc_type, exc_val, exc_tb):
220-
pass
221-
222-
223221
@pytest.mark.parametrize("redundant_unit, expectation", [
224-
("", not_raises()),
222+
("", do_not_raise()),
225223
("d", pytest.raises(ValueError)),
226224
("us", pytest.raises(ValueError))])
227225
@pytest.mark.parametrize("unit", [

0 commit comments

Comments
 (0)