Skip to content

Commit

Permalink
Fix two Python test warnings
Browse files Browse the repository at this point in the history
* test_init_ndarray_deprecated: the test is expected to trigger a deprecation warning. I have added a pytest context manager to 1) ensure it does and 2) remove the deprecation warning from the test output

* test_extract_regex: use a raw format string to deal with the \w sequence
  • Loading branch information
zundertj authored and ritchie46 committed Nov 6, 2021
1 parent 94f838a commit c9eb258
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions py-polars/tests/test_df.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ def test_init_ndarray():

# TODO: Remove this test case when removing deprecated behaviour
def test_init_ndarray_deprecated():
# 2D array - default to row orientation
df = pl.DataFrame(np.array([[1, 2], [3, 4]]))
truth = pl.DataFrame({"column_0": [1, 3], "column_1": [2, 4]})
assert df.frame_equal(truth)
with pytest.deprecated_call():
# 2D array - default to row orientation
df = pl.DataFrame(np.array([[1, 2], [3, 4]]))
truth = pl.DataFrame({"column_0": [1, 3], "column_1": [2, 4]})
assert df.frame_equal(truth)


def test_init_arrow():
Expand Down
2 changes: 1 addition & 1 deletion py-polars/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ def test_extract_regex():
"http://vote.com/ballon_dor?candidate=ronaldo&ref=polars",
]
)
assert s.str.extract("candidate=(\w+)", 1).to_list() == [
assert s.str.extract(r"candidate=(\w+)", 1).to_list() == [
"messi",
None,
"ronaldo",
Expand Down

0 comments on commit c9eb258

Please sign in to comment.