From e5872248a6e95f822f0f8592137cec60336118a8 Mon Sep 17 00:00:00 2001 From: Taka Date: Fri, 27 Nov 2020 23:33:18 +1100 Subject: [PATCH] Fixed a test that was failing on Windows. --- vasl_templates/webapp/tests/control_tests_servicer.py | 4 ++++ vasl_templates/webapp/vasl_mod.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/vasl_templates/webapp/tests/control_tests_servicer.py b/vasl_templates/webapp/tests/control_tests_servicer.py index c8c0206..02c2dc1 100644 --- a/vasl_templates/webapp/tests/control_tests_servicer.py +++ b/vasl_templates/webapp/tests/control_tests_servicer.py @@ -174,6 +174,10 @@ class ControlTestsServicer( BaseControlTestsServicer ): #pylint: disable=too-man """End a test run.""" self._log_request( request, context ) # end the test run + # NOTE: If the active VaslMod has loaded any extension files from our temp directory, since they are + # kept open for the duration, we need to clean up the VaslMod (so that it will close these files), + # otherwise we may not be able to clean up our temp file directory. + webapp_vasl_mod.set_vasl_mod( None, None ) self.cleanup() return Empty() diff --git a/vasl_templates/webapp/vasl_mod.py b/vasl_templates/webapp/vasl_mod.py index dba72ca..f178adc 100644 --- a/vasl_templates/webapp/vasl_mod.py +++ b/vasl_templates/webapp/vasl_mod.py @@ -172,6 +172,13 @@ class VaslMod: if self.vasl_version not in SUPPORTED_VASL_MOD_VERSIONS: _logger.warning( "Unsupported VASL version: %s", self.vasl_version ) + def __del__( self ): + # clean up + # NOTE: We keep our module and extension ZIP files open for the duration (so we can + # read images out of them on demand), so we need to make sure we close them here. + for f in self._files: + f[0].close() + def get_piece_image( self, gpid, side, index ): """Get the image for the specified piece."""