diff options
author | Frederick Muriuki Muriithi | 2022-04-13 10:01:57 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-04-13 10:01:57 +0300 |
commit | 0cc8fd5fb2a026662dc2bd12f6bad9f68e5da5b0 (patch) | |
tree | 9459aa5588b3f53b99076cac87d1d60c85b2aa68 | |
parent | d4c2c2fccb038cdba5cc618437a0b5f67064b1b2 (diff) | |
download | gn-uploader-0cc8fd5fb2a026662dc2bd12f6bad9f68e5da5b0.tar.gz |
Update Exception name
Change the exception name to be more descriptive.
-rw-r--r-- | quality_control/average.py | 4 | ||||
-rw-r--r-- | quality_control/errors.py | 2 | ||||
-rw-r--r-- | quality_control/standard_error.py | 4 | ||||
-rw-r--r-- | tests/qc/test_cells.py | 10 |
4 files changed, 10 insertions, 10 deletions
diff --git a/quality_control/average.py b/quality_control/average.py index 1a7bf5f..c552ba3 100644 --- a/quality_control/average.py +++ b/quality_control/average.py @@ -1,12 +1,12 @@ """Contain logic for checking average files""" import re -from .errors import InvalidValue +from .errors import InvalidCellValue def valid_value(val): if re.search("^[0-9]+\.[0-9]{3}$", val): return float(val) - raise InvalidValue( + raise InvalidCellValue( f"Invalid value '{val}'.\n" "Expected string representing a number with exactly three decimal " "places.") diff --git a/quality_control/errors.py b/quality_control/errors.py index a77039b..99f9c97 100644 --- a/quality_control/errors.py +++ b/quality_control/errors.py @@ -1,6 +1,6 @@ """Hold exceptions for QC package""" -class InvalidValue(Exception): +class InvalidCellValue(Exception): """Raised when a function encounters an invalid value""" def __init__(self, *args): diff --git a/quality_control/standard_error.py b/quality_control/standard_error.py index ae1e378..7b49913 100644 --- a/quality_control/standard_error.py +++ b/quality_control/standard_error.py @@ -1,12 +1,12 @@ """Contain logic for checking standard error files""" import re -from .errors import InvalidValue +from .errors import InvalidCellValue def valid_value(val): if re.search("^[0-9]+\.[0-9]{6,}$", val): return float(val) - raise InvalidValue( + raise InvalidCellValue( f"Invalid value '{val}'.\n" "Expected string representing a number with at least six decimal " "places.") diff --git a/tests/qc/test_cells.py b/tests/qc/test_cells.py index b105286..5e25a9a 100644 --- a/tests/qc/test_cells.py +++ b/tests/qc/test_cells.py @@ -4,20 +4,20 @@ import pytest from hypothesis import given from hypothesis import strategies as st -from quality_control.errors import InvalidValue +from quality_control.errors import InvalidCellValue from quality_control.average import valid_value as avg_valid_value from quality_control.standard_error import valid_value as se_valid_value @given(num_str=st.from_regex("^(?!([0-9]+\.([0-9]{3}|[0-9]{6,}))).*", fullmatch=True)) def test_cell_value_errors_with_invalid_inputs(num_str): - with pytest.raises(InvalidValue): + with pytest.raises(InvalidCellValue): avg_valid_value(num_str) - with pytest.raises(InvalidValue): + with pytest.raises(InvalidCellValue): se_valid_value(num_str) @given(num_str=st.from_regex("^[0-9]+\.([0-9]{1,2}|[0-9]{4,}$)", fullmatch=True)) def test_cell_average_value_errors_if_not_three_decimal_places(num_str): - with pytest.raises(InvalidValue): + with pytest.raises(InvalidCellValue): avg_valid_value(num_str) @given(num_str=st.from_regex("^[0-9]+\.[0-9]{3}$", fullmatch=True)) @@ -29,7 +29,7 @@ def test_cell_average_value_pass_if_three_decimal_places(num_str): @given(num_str=st.from_regex("^[0-9]+\.([0-9]{0,5}$)", fullmatch=True)) def test_cell_standard_error_value_errors_if_less_than_six_decimal_places(num_str): - with pytest.raises(InvalidValue): + with pytest.raises(InvalidCellValue): se_valid_value(num_str) @given(num_str=st.from_regex("^[0-9]+\.[0-9]{6,}$", fullmatch=True)) |