Skip to content

Commit

Permalink
test: minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
eitsupi committed Sep 13, 2024
1 parent 7979cb5 commit aa36918
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/testthat/test-as_polars_expr.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,19 @@ patrick::with_parameters_test_that(
expect_snapshot(selected_out)

# Ensure broadcasting works if the length is 1 (except for Series)
lf <- pl$LazyFrame(a = 1:10)$with_columns(b = out)

if (expected_length == 1 && !is_polars_series(x)) {
expect_no_error(pl$DataFrame(a = 1:10)$with_columns(b = out))
expect_no_error(lf$collect())
} else if (expected_length == 1) {
# For Series with length 1, a special error message is thrown
expect_error(
pl$DataFrame(a = 1:10)$with_columns(b = out),
lf$collect(),
r"(length 1 doesn't match the DataFrame height of 10.*for instance by adding '\.first\(\)')"
)
} else {
expect_error(
pl$DataFrame(a = 1:10)$with_columns(b = out),
lf$collect(),
r"(unable to add a column of length \d+ to a DataFrame of height 10)"
)
}
Expand Down

0 comments on commit aa36918

Please sign in to comment.