From af53102e7752672312ca074df9ead9accccf0e5c Mon Sep 17 00:00:00 2001 From: Curtis Gedak Date: Thu, 1 Nov 2018 12:54:35 -0600 Subject: [PATCH] Fix pytest warning about duplicate name when running tests When running pytest on kubuntu 16.04 the following warning was displayed: $ python3 -m pytest -v ... ./manuskript/load_save/version_1.py:319: \ UserWarning: Duplicate name: 'outline/0-Folder/0-Text-3.md' zf.writestr(filename, content, compress_type=compression) The error was tracked down using the following pytest invocation: $ python3 -m pytest -v -W error::UserWarning This invocation showed 4 occurrences similar to the following warning: self = zinfo = <[AttributeError("compress_size") raised in repr()] \ ZipInfo object at 0x7f3cc0124588> def _writecheck(self, zinfo): """Check for errors before writing a file to the archive.""" if zinfo.filename in self.NameToInfo: import warnings > warnings.warn('Duplicate name: %r' % zinfo.filename, \ stacklevel=3) E UserWarning: Duplicate name: 'outline/0-Folder/0-Text-3.md' These warnings arose in the following 4 tests: - test_references - test_autoLoad - test_loadExportWiget - test_loadImportWiget The cause of the issue is that in manuskript/tests/conftest.py, the mainWindow::closeProject() method is called to close the project, but the project was never loaded. This meant the zip file setting defaulted to True, when in fact the Acts sample project is not stored in a single zip project file. Fix by removing the call to MW.closeProject() before the project is loaded. --- manuskript/tests/conftest.py | 1 - 1 file changed, 1 deletion(-) diff --git a/manuskript/tests/conftest.py b/manuskript/tests/conftest.py index be2403df..09629e47 100644 --- a/manuskript/tests/conftest.py +++ b/manuskript/tests/conftest.py @@ -66,7 +66,6 @@ def MWSampleProject(MW): import shutil shutil.copyfile(src, tf.name) shutil.copytree(src[:-4], tf.name[:-4]) - MW.closeProject() MW.loadProject(tf.name) assert MW.currentProject is not None