Skip to content

Instantly share code, notes, and snippets.

@andrewdoss-bit
Created September 23, 2021 18:05
Show Gist options
  • Save andrewdoss-bit/271bfe18d1eda3e86fe6a94d989c6a5a to your computer and use it in GitHub Desktop.
Save andrewdoss-bit/271bfe18d1eda3e86fe6a94d989c6a5a to your computer and use it in GitHub Desktop.
Unit testing fips_cleaner
@pytest.mark.parametrize(
"input, expected",
[
('01001', '01001'), # 5-character string in, 5-character string out
('1001', '01001'), # 4-character string in, 5-character string out
(1001, '01001'), # int in, 5-character string out
(1001.0, '01001'), # float in, 5-character string out
('11001', '11001'), # Similar to before, but with two digit state code
(11001, '11001'), # Similar to before, but with two digit state code
(11001.0, '11001'), # Similar to before, but with two digit state code
]
)
def test_fips_cleaner(input, expected):
input_series = pd.Series([input]) # Setup
cleaned_value = fips_cleaner(input_series).iloc[0] # Compute
assert cleaned_value == expected # Assert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment