-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcheck_null_test.py
More file actions
33 lines (26 loc) · 1004 Bytes
/
check_null_test.py
File metadata and controls
33 lines (26 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from codonpython.check_null import check_null
import numpy as np
import pandas as pd
import pytest
testdata = pd.DataFrame(
{
"col1": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
"col2": [11, 12, 13, 14, 15, np.nan, np.nan, 18, 19, 20],
}
)
@pytest.mark.parametrize(
"dataframe, columns_to_be_checked, expected",
[(testdata.iloc[:5, :], ["col1", "col2"], 0), (testdata, ["col2"], 2)],
)
def test_BAU(dataframe, columns_to_be_checked, expected):
assert check_null(dataframe, columns_to_be_checked) == expected
@pytest.mark.parametrize("dataframe, columns_to_be_checked", [(testdata, 0.01)])
def test_ValueError(dataframe, columns_to_be_checked):
with pytest.raises(ValueError):
check_null(dataframe, columns_to_be_checked)
@pytest.mark.parametrize(
"dataframe, columns_to_be_checked", [(testdata, ["wrong_column"])]
)
def test_KeyError(dataframe, columns_to_be_checked):
with pytest.raises(KeyError):
check_null(dataframe, columns_to_be_checked)