From 1b61b59dcc8e92cbeaedfa7183df281555ba2828 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 8 Feb 2024 04:00:20 +0300 Subject: Use error objects rather than plain tuple values. --- tests/r_qtl/test_r_qtl2_qc.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/r_qtl/test_r_qtl2_qc.py b/tests/r_qtl/test_r_qtl2_qc.py index 1c96a86..554cfc4 100644 --- a/tests/r_qtl/test_r_qtl2_qc.py +++ b/tests/r_qtl/test_r_qtl2_qc.py @@ -6,6 +6,9 @@ from zipfile import ZipFile from r_qtl import r_qtl2 as rqtl2 from r_qtl import r_qtl2_qc as rqc +from r_qtl.fileerrors import MissingFile + +from quality_control.errors import InvalidValue @pytest.mark.unit_test @pytest.mark.parametrize( @@ -85,13 +88,13 @@ def test_missing_files(filepath, expected): @pytest.mark.parametrize( "filepath,expected", (("tests/r_qtl/test_files/empty_control_file_yaml.zip", - ((None, None, "Missing 'geno' file."),)), + (MissingFile("geno", None, "Missing 'geno' file 'None'."),)), ("tests/r_qtl/test_files/test_geno.zip", tuple()), ("tests/r_qtl/test_files/geno_with_missing_genotypes.zip", - ((1, "AXR-1", "Invalid value 'X'. Expected one of ('L', 'C')"), - (2, "EC.480C", "Invalid value 'Y'. Expected one of ('L', 'C')"), - (6, "HH.335C-Col/PhyA", f"Invalid value 'H'. Expected one of ('L', 'C')"))))) + (InvalidValue(1, "AXR-1", "X", "Invalid value 'X'. Expected one of ('L', 'C')."), + InvalidValue(2, "EC.480C", "Y", "Invalid value 'Y'. Expected one of ('L', 'C')."), + InvalidValue(6, "HH.335C-Col/PhyA", "H", f"Invalid value 'H'. Expected one of ('L', 'C')."))))) def test_geno_errors(filepath, expected): """ GIVEN: A R/qtl2 bundle @@ -106,14 +109,14 @@ def test_geno_errors(filepath, expected): @pytest.mark.parametrize( "filepath,expected", (("tests/r_qtl/test_files/empty_control_file_yaml.zip", - ((None, None, "Missing 'pheno' file."),)), + (MissingFile("pheno", None, "Missing 'pheno' file 'None'."),)), ("tests/r_qtl/test_files/pheno_without_errors.zip", tuple()), ("tests/r_qtl/test_files/pheno_with_errors.zip", - ((1, "liver", ("Invalid value '61.92'. Expected numerical value " - "with at least 3 decimal places.")), - (2, "spleen", ("Invalid value 'brrr'. Expected numerical value " - "with at least 3 decimal places.")))))) + (InvalidValue(1, "liver", "61.92", ("Invalid value '61.92'. Expected numerical value " + "with at least 3 decimal places.")), + InvalidValue(2, "spleen", "brrr", ("Invalid value 'brrr'. Expected numerical value " + "with at least 3 decimal places.")))))) def test_pheno_errors(filepath, expected): """ GIVEN: A R/qtl2 bundle -- cgit v1.2.3