diff --git a/setup.py b/setup.py index 04803fa..1da20de 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup(name='sbol_factory', description='Ontology-driven data modeling', - version='1.0a12', + version='1.0a13', install_requires=[ 'sbol3>=1.0b12', # Note: implicitly includes rdflib 'sparqlwrapper>=1.8.5', diff --git a/test/test_ontology.py b/test/test_ontology.py index e440a7d..cfc1ca6 100644 --- a/test/test_ontology.py +++ b/test/test_ontology.py @@ -72,20 +72,14 @@ def test_build_with_ontology(self): v = doc.validate() assert not v.errors and not v.warnings, "".join(str(e) for e in doc.validate().errors) - temp_name = os.path.join(tempfile.gettempdir(), 'mini_library.nt') - doc.write(temp_name, sbol3.SORTED_NTRIPLES) + actual = doc.write_string(file_format=sbol3.SORTED_NTRIPLES) - #Use \n as a newline instead of \r\n for windows compatibility - with open(temp_name) as f: - file_str = f.read() - with open(temp_name, "w", newline='\n') as f: - f.write(file_str) - - print(f'Wrote file as {temp_name}') - comparison_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test_files', 'mini_library.nt') print(f'Comparing against {comparison_file}') - assert filecmp.cmp(temp_name, comparison_file), "Files are not identical" + doc = sbol3.Document() + doc.read(comparison_file) + expected = doc.write_string(file_format=sbol3.SORTED_NTRIPLES) + assert expected == actual print('File identical with test file') def test_round_trip_with_ontology(self): @@ -98,19 +92,12 @@ def test_round_trip_with_ontology(self): v = doc.validate() assert not v.errors and not v.warnings, "".join(str(e) for e in doc.validate().errors) - temp_name = os.path.join(tempfile.gettempdir(), 'mini_library.nt') - doc.write(temp_name, sbol3.SORTED_NTRIPLES) - - #Use \n as a newline instead of \r\n for windows compatibility - with open(temp_name) as f: - file_str = f.read() - with open(temp_name, "w", newline='\n') as f: - f.write(file_str) - - print(f'Wrote file as {temp_name}') + with open(original_file, 'r') as f: + expected = f.read() + actual = doc.write_string(file_format=sbol3.SORTED_NTRIPLES) print(f'Comparing against {original_file}') - assert filecmp.cmp(temp_name, original_file), "Files are not identical" + assert actual == expected, "Files are not identical" print('Written out file identical with original file')