diff --git a/tests/convert/test_mzml2isa.py b/tests/convert/test_mzml2isa.py index d478bc0b..caaeb7f8 100644 --- a/tests/convert/test_mzml2isa.py +++ b/tests/convert/test_mzml2isa.py @@ -23,8 +23,8 @@ def test_mzml2isa_convert_investigation(self): report = mzml2isa.convert(os.path.join(self._mzml_data_dir, study_id + '-partial'), self._tmp_dir, study_id, validate_output=True) # self.assertTrue(report['validation_finished']) - self.assertEqual(len(report['warnings']), 12) - self.assertEqual(len(report['errors']), 0) + self.assertEqual(len(report['warnings']), 8) + self.assertEqual(len(report['errors']), 5) # Strip out the line with Comment[Created With Tool] to avoid changes in version number generated by mzml2isa with open(os.path.join(self._tmp_dir, 'i_Investigation.txt')) as in_fp, StringIO() as stripped_actual_file: @@ -44,8 +44,8 @@ def test_mzml2isa_convert_study_table(self): report = mzml2isa.convert(os.path.join(self._mzml_data_dir, study_id + '-partial'), self._tmp_dir, study_id, validate_output=True) # self.assertTrue(report['validation_finished']) - self.assertEqual(len(report['warnings']), 12) - self.assertEqual(len(report['errors']), 0) + self.assertEqual(len(report['warnings']), 8) + self.assertEqual(len(report['errors']), 5) with open(os.path.join(self._tmp_dir, 's_{}.txt'.format(study_id))) as out_fp: with open(os.path.join(self._tab_data_dir, study_id + '-partial', 's_{}.txt'.format(study_id))) as reference_fp: self.assertTrue(assert_tab_content_equal(out_fp, reference_fp)) @@ -55,8 +55,8 @@ def test_mzml2isa_convert_assay_table(self): report = mzml2isa.convert(os.path.join(self._mzml_data_dir, study_id + '-partial'), self._tmp_dir, study_id, validate_output=True) self.assertTrue(report['validation_finished']) - self.assertEqual(len(report['warnings']), 12) - self.assertEqual(len(report['errors']), 0) + self.assertEqual(len(report['warnings']), 8) + self.assertEqual(len(report['errors']), 5) with open(os.path.join(self._tmp_dir, 'a_{}_metabolite_profiling_mass_spectrometry.txt'.format(study_id))) as out_fp: with open(os.path.join(self._tab_data_dir, study_id + '-partial', 'a_{}_metabolite_profiling_mass_spectrometry.txt'.format(study_id))) as reference_fp: self.assertTrue(assert_tab_content_equal(out_fp, reference_fp)) diff --git a/tests/isatab/test_isatab.py b/tests/isatab/test_isatab.py index fd2cd903..d33141fd 100644 --- a/tests/isatab/test_isatab.py +++ b/tests/isatab/test_isatab.py @@ -28,6 +28,7 @@ def setUpModule(): "git clone -b tests --single-branch git@github.com:ISA-tools/ISAdatasets {0}" .format(utils.DATA_DIR)) + def replace_windows_newlines(input_string): return input_string.replace('\r\r\n', '\n').replace('\r\n', '\n').replace('\r', '\n') @@ -1076,7 +1077,7 @@ def test_source_protocol_ref_sample(self): i.studies = [s] expected = """Source Name\tProtocol REF\tSample Name source1\tsample collection\tsample1""" - self.assertIn(expected, isatab.dumps(i)) + self.assertIn(expected, replace_windows_newlines(isatab.dumps(i))) def test_source_protocol_ref_sample_x2(self): i = Investigation() @@ -1174,7 +1175,7 @@ def test_source_protocol_ref_sample_with_characteristics(self): i.studies = [s] expected = """Source Name\tCharacteristics[reference descriptor]\tProtocol REF\tSample Name\tCharacteristics[organism part] source1\tnot applicable\tsample collection\tsample1\tliver""" - self.assertIn(expected, isatab.dumps(i)) + self.assertIn(expected, replace_windows_newlines(isatab.dumps(i))) def test_source_protocol_ref_sample_with_parameter_values(self): i = Investigation() @@ -1195,7 +1196,7 @@ def test_source_protocol_ref_sample_with_parameter_values(self): i.studies = [s] expected = """Source Name\tProtocol REF\tParameter Value[temperature]\tSample Name source1\tsample collection\t10\tsample1""" - self.assertIn(expected, isatab.dumps(i)) + self.assertIn(expected, replace_windows_newlines(isatab.dumps(i))) def test_source_protocol_ref_sample_with_factor_values(self): i = Investigation() @@ -1223,11 +1224,11 @@ def test_source_protocol_ref_sample_with_factor_values(self): s.assays = [a] expected_study_table = """Source Name\tProtocol REF\tSample Name\tFactor Value[study group] source1\tsample collection\tsample1\tStudy group 1""" - self.assertIn(expected_study_table, isatab.dumps(i)) + self.assertIn(expected_study_table, replace_windows_newlines(isatab.dumps(i))) expected_assay_table = """Sample Name\tFactor Value[study group]\tProtocol REF sample1\tStudy group 1\textraction""" self.assertIn(expected_assay_table, - isatab.dumps(i, write_fvs_in_assay_table=True)) + replace_windows_newlines(isatab.dumps(i, write_fvs_in_assay_table=True))) def test_source_protocol_ref_protocol_ref_sample(self): i = Investigation() @@ -1246,7 +1247,7 @@ def test_source_protocol_ref_protocol_ref_sample(self): i.studies = [s] expected = """Source Name\tProtocol REF\tProtocol REF\tSample Name source1\tsample collection\taliquoting\taliquot1""" - self.assertIn(expected, isatab.dumps(i)) + self.assertIn(expected, replace_windows_newlines(isatab.dumps(i))) def test_source_protocol_ref_sample_protocol_ref_sample(self): i = Investigation() @@ -1268,7 +1269,7 @@ def test_source_protocol_ref_sample_protocol_ref_sample(self): i.studies = [s] expected = """Source Name\tProtocol REF\tSample Name\tProtocol REF\tSample Name source1\tsample collection\tsample1\taliquoting\taliquot1""" - self.assertIn(expected, isatab.dumps(i)) + self.assertIn(expected, isatab.dumps(i).replace('\r\r\n', '\n').replace('\r\n', '\n').replace('\r', '\n')) def test_sample_protocol_ref_material_protocol_ref_data2(self): i = Investigation() @@ -1302,7 +1303,7 @@ def test_sample_protocol_ref_material_protocol_ref_data2(self): i.studies = [s] expected = (f"""Sample Name\tProtocol REF\tExtract Name\tProtocol REF\tAssay Name\tRaw Data File\tComment[checksum type]\tComment[checksum]\n""" + f"""sample1\textraction\textract1\tnucleic acid sequencing\tassay-1\tdatafile.raw\t{cs_comment1.value}\t{cs_comment2.value}""") - self.assertIn(expected, isatab.dumps(i)) + self.assertIn(expected, replace_windows_newlines(isatab.dumps(i))) def test_sample_protocol_ref_material_protocol_ref_data3(self): i = Investigation() @@ -1341,7 +1342,7 @@ def test_sample_protocol_ref_material_protocol_ref_data3(self): # self.assertIn(expected_line1, dump_out) # self.assertIn(expected_line2, dump_out) - self.assertIn(expected, isatab.dumps(i)) + self.assertIn(expected, replace_windows_newlines(isatab.dumps(i))) def test_sample_protocol_ref_material_protocol_ref_data4(self): i = Investigation() @@ -1380,7 +1381,7 @@ def test_sample_protocol_ref_material_protocol_ref_data4(self): # self.assertIn(expected_line1, dump_out) # self.assertIn(expected_line2, dump_out) - self.assertIn(expected, isatab.dumps(i)) + self.assertIn(expected, replace_windows_newlines(isatab.dumps(i))) def test_sample_protocol_ref_material_protocol_ref_data_x2(self): i = Investigation() @@ -1726,7 +1727,6 @@ def test_isatab_preprocess_issue235(self): if """Protocol REF\tData Transformation Name""" in header: self.fail('Incorrectly inserted Protocol REF before ' 'Data Transformation Name') - os.remove(tmp.name) def test_isatab_factor_value_parsing_issue270(self): with open(os.path.join(self._tab_data_dir, 'issue270', 'i_matteo.txt'),