Beispiel #1
0
def test_max_field_len_parameter(test_dataframe):
    """
    Test.
    """
    with pytest.raises(AssertionError):
        sample_row(test_dataframe, random_state="a")
    with pytest.raises(AssertionError):
        sample_row(test_dataframe, random_state=None)
Beispiel #2
0
def test_filter_rows_with_na_parameter(na_col_dataframe):
    """
    Test.
    """
    with pytest.raises(AssertionError):
        sample_row(test_dataframe, filter_rows_with_na="a")
    with pytest.raises(AssertionError):
        sample_row(test_dataframe, filter_rows_with_na=None)
Beispiel #3
0
def test_df_with_nan_in_row(na_in_row_dataframe, expected_na_in_row_return):
    pd.testing.assert_frame_equal(
        sample_row(na_in_row_dataframe,
                   random_state=42,
                   filter_rows_with_na=True),
        expected_na_in_row_return,
    )
Beispiel #4
0
def test_df_with_nan_column(na_col_dataframe, expected_na_col_return_w_filtering, caplog):
    """
    Test.
    """
    with caplog.at_level("INFO"):
        pd.testing.assert_frame_equal(
            sample_row(na_col_dataframe, random_state=42, filter_rows_with_na=True),
            expected_na_col_return_w_filtering,
        )

    assert "No rows without NaN found, sampling from all rows.." in caplog.text
Beispiel #5
0
def test_long_str_df(long_str_dataframe, expected_long_str_return):
    """
    Test.
    """
    pd.testing.assert_frame_equal(sample_row(long_str_dataframe, random_state=42), expected_long_str_return)
Beispiel #6
0
def test_empty_df(empty_dataframe):
    """
    Test.
    """
    with pytest.raises(AssertionError):
        sample_row(empty_dataframe)
Beispiel #7
0
def test_normal_df(test_dataframe, expected_test_return):
    """
    Test.
    """
    pd.testing.assert_frame_equal(sample_row(test_dataframe), expected_test_return)
Beispiel #8
0
def test_random_state_parameter(test_dataframe):
    with pytest.raises(AssertionError):
        sample_row(test_dataframe, random_state="a")
    with pytest.raises(AssertionError):
        sample_row(test_dataframe, random_state=None)