Skip to content

Commit

Permalink
Fix #218: change tests from using NamedTemporaryfile to TemporaryDire…
Browse files Browse the repository at this point in the history
…ctory in order to be compatible with Windows tempfile restrictions
  • Loading branch information
jakebeal committed Oct 12, 2023
1 parent b5acb89 commit 2827f3a
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions test/test_sbol2_sbol3_direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ def test_3to2_conversion(self):
doc2 = convert3to2(doc3, True)
#report = doc2.validate()
#self.assertEqual(len(report), 0, f'Validation failed: {report}')
with tempfile.NamedTemporaryFile(suffix='.xml') as tmp2:
doc2.write(tmp2.name)
self.assertFalse(file_diff(tmp2.name, str(TEST_FILES / 'BBa_J23101.xml')))
with tempfile.TemporaryDirectory() as tmpdir:
tmp2 = Path(tmpdir) / 'doc2.xml'
doc2.write(tmp2)
self.assertFalse(file_diff(str(tmp2), str(TEST_FILES / 'BBa_J23101.xml')))
doc3_loop = convert2to3(doc2, use_native_converter=True)
self.assertEqual(len(doc3_loop.validate()), 0)
with tempfile.NamedTemporaryFile(suffix='.nt') as tmp3:
doc3_loop.write(tmp3.name)
self.assertFalse(file_diff(tmp3.name, str(TEST_FILES / 'BBa_J23101_patched.nt')))
tmp3 = Path(tmpdir) / 'doc3_loop.nt'
doc3_loop.write(tmp3)
self.assertFalse(file_diff(str(tmp3), str(TEST_FILES / 'BBa_J23101_patched.nt')))

def test_2to3_conversion(self):
"""Test ability to convert a simple part from SBOL3 to SBOL2"""
Expand All @@ -41,15 +42,16 @@ def test_2to3_conversion(self):
# Convert to SBOL3 and check contents
doc3 = convert2to3(doc2, use_native_converter=True)
self.assertEqual(len(doc3.validate()), 0)
with tempfile.NamedTemporaryFile(suffix='.nt') as tmp3:
doc3.write(tmp3.name)
self.assertFalse(file_diff(tmp3.name, str(TEST_FILES / 'BBa_J23101_patched.nt')))
with tempfile.TemporaryDirectory() as tmpdir:
tmp3 = Path(tmpdir) / 'doc3.nt'
doc3.write(tmp3)
self.assertFalse(file_diff(str(tmp3), str(TEST_FILES / 'BBa_J23101_patched.nt')))
doc2_loop = convert3to2(doc3, True)
# report = doc2.validate()
# self.assertEqual(len(report), 0, f'Validation failed: {report}')
with tempfile.NamedTemporaryFile(suffix='.xml') as tmp2:
doc2_loop.write(tmp2.name)
self.assertFalse(file_diff(tmp2.name, str(TEST_FILES / 'BBa_J23101.xml')))
tmp2 = Path(tmpdir) / 'doc2_loop.xml'
doc2_loop.write(tmp2)
self.assertFalse(file_diff(str(tmp2), str(TEST_FILES / 'BBa_J23101.xml')))


if __name__ == '__main__':
Expand Down

0 comments on commit 2827f3a

Please sign in to comment.