|
1 |
| -import pytest |
2 | 1 | from typing import Any
|
3 |
| -from unittest.mock import patch, PropertyMock |
| 2 | +from unittest.mock import PropertyMock, patch |
| 3 | + |
| 4 | +import pytest |
| 5 | + |
4 | 6 | from pandas.core.computation.pytables import BinOp, TermValue
|
5 | 7 | from pandas.core.series import Series
|
6 | 8 |
|
7 | 9 |
|
8 |
| -@patch('pandas.core.computation.pytables.BinOp.kind', new_callable=PropertyMock, return_value='integer') |
9 |
| -@patch('pandas.core.computation.pytables.BinOp.meta', new_callable=PropertyMock, return_value='category') |
10 |
| -@patch('pandas.core.computation.pytables.BinOp.metadata', new_callable=PropertyMock, return_value=Series(data=['a', 'b', 's'])) |
11 |
| -@pytest.mark.parametrize("value, expected_results", |
12 |
| - [('q', |
13 |
| - TermValue(-1, -1, 'integer')), |
14 |
| - ('a', |
15 |
| - TermValue(0, 0, 'integer'))]) |
16 |
| -def test_convert_value(mock_kind, |
17 |
| - mock_meta, |
18 |
| - mock_metadata, |
19 |
| - value: Any, |
20 |
| - expected_results: TermValue): |
| 10 | +@patch( |
| 11 | + "pandas.core.computation.pytables.BinOp.kind", |
| 12 | + new_callable=PropertyMock, |
| 13 | + return_value="integer", |
| 14 | +) |
| 15 | +@patch( |
| 16 | + "pandas.core.computation.pytables.BinOp.meta", |
| 17 | + new_callable=PropertyMock, |
| 18 | + return_value="category", |
| 19 | +) |
| 20 | +@patch( |
| 21 | + "pandas.core.computation.pytables.BinOp.metadata", |
| 22 | + new_callable=PropertyMock, |
| 23 | + return_value=Series(data=["a", "b", "s"]), |
| 24 | +) |
| 25 | +@pytest.mark.parametrize( |
| 26 | + "value, expected_results", |
| 27 | + [("q", TermValue(-1, -1, "integer")), ("a", TermValue(0, 0, "integer"))], |
| 28 | +) |
| 29 | +def test_convert_value( |
| 30 | + mock_kind, mock_meta, mock_metadata, value: Any, expected_results: TermValue |
| 31 | +): |
21 | 32 |
|
22 | 33 | with patch.object(BinOp, "__init__", lambda p1, p2, p3, p4, p5, p6: None):
|
23 | 34 | bin_op = BinOp(None, None, None, None, None)
|
24 |
| - bin_op.encoding = 'UTF-8' |
| 35 | + bin_op.encoding = "UTF-8" |
25 | 36 |
|
26 | 37 | result = bin_op.convert_value(value)
|
27 | 38 |
|
28 |
| - assert result.kind == expected_results.kind and\ |
29 |
| - result.value == expected_results.value and\ |
30 |
| - result.converted == expected_results.converted |
| 39 | + assert ( |
| 40 | + result.kind == expected_results.kind |
| 41 | + and result.value == expected_results.value |
| 42 | + and result.converted == expected_results.converted |
| 43 | + ) |
0 commit comments