Commit ca27b066a5eab4bb61bde07e7734432d2135db22
1 parent
6ae89c9a
Disable some unittests for PyPy on Windows
Decrypting test samples "on the fly" using a generator causes trouble when removing the temp file, PyPy/Windows thinks the file is still being used.
Showing
2 changed files
with
21 additions
and
0 deletions
tests/msodde/test_basic.py
| @@ -9,6 +9,7 @@ Ensure that | @@ -9,6 +9,7 @@ Ensure that | ||
| 9 | from __future__ import print_function | 9 | from __future__ import print_function |
| 10 | 10 | ||
| 11 | import unittest | 11 | import unittest |
| 12 | +from platform import python_implementation | ||
| 12 | import sys | 13 | import sys |
| 13 | import os | 14 | import os |
| 14 | from os.path import join, basename | 15 | from os.path import join, basename |
| @@ -19,8 +20,21 @@ from tests.test_utils import call_and_capture, decrypt_sample,\ | @@ -19,8 +20,21 @@ from tests.test_utils import call_and_capture, decrypt_sample,\ | ||
| 19 | DATA_BASE_DIR as BASE_DIR | 20 | DATA_BASE_DIR as BASE_DIR |
| 20 | 21 | ||
| 21 | 22 | ||
| 23 | +# Check whether we run with PyPy on windows because that causes trouble | ||
| 24 | +# when using the :py:func:`tests.test_utils.decrypt_sample`. | ||
| 25 | +# | ||
| 26 | +# :return: `(do_skip, explanation)` where `do_skip` is `True` iff running | ||
| 27 | +# PyPy on Windows; `explanation` is a simple text string | ||
| 28 | +SKIP_PYPY_WIN = ( | ||
| 29 | + python_implementation().lower().startswith('pypy') | ||
| 30 | + and sys.platform.lower().startswith('win'), | ||
| 31 | + "On PyPy there is a problem with deleting temp files for decrypt_sample" | ||
| 32 | +) | ||
| 33 | + | ||
| 34 | + | ||
| 22 | class TestReturnCode(unittest.TestCase): | 35 | class TestReturnCode(unittest.TestCase): |
| 23 | """ check return codes and exception behaviour (not text output) """ | 36 | """ check return codes and exception behaviour (not text output) """ |
| 37 | + @unittest.skipIf(*SKIP_PYPY_WIN) | ||
| 24 | def test_valid_doc(self): | 38 | def test_valid_doc(self): |
| 25 | """ check that a valid doc file leads to 0 exit status """ | 39 | """ check that a valid doc file leads to 0 exit status """ |
| 26 | for filename in ( | 40 | for filename in ( |
| @@ -44,6 +58,7 @@ class TestReturnCode(unittest.TestCase): | @@ -44,6 +58,7 @@ class TestReturnCode(unittest.TestCase): | ||
| 44 | self.do_test_validity(join(BASE_DIR, 'msodde', | 58 | self.do_test_validity(join(BASE_DIR, 'msodde', |
| 45 | filename + '.docm')) | 59 | filename + '.docm')) |
| 46 | 60 | ||
| 61 | + @unittest.skipIf(*SKIP_PYPY_WIN) | ||
| 47 | def test_valid_xml(self): | 62 | def test_valid_xml(self): |
| 48 | """ check that xml leads to 0 exit status """ | 63 | """ check that xml leads to 0 exit status """ |
| 49 | for filename in ( | 64 | for filename in ( |
| @@ -140,6 +155,7 @@ class TestDdeLinks(unittest.TestCase): | @@ -140,6 +155,7 @@ class TestDdeLinks(unittest.TestCase): | ||
| 140 | """ | 155 | """ |
| 141 | return [o for o in output.splitlines()] | 156 | return [o for o in output.splitlines()] |
| 142 | 157 | ||
| 158 | + @unittest.skipIf(*SKIP_PYPY_WIN) | ||
| 143 | def test_with_dde(self): | 159 | def test_with_dde(self): |
| 144 | """ check that dde links appear on stdout """ | 160 | """ check that dde links appear on stdout """ |
| 145 | filename = 'dde-test-from-office2003.doc.zip' | 161 | filename = 'dde-test-from-office2003.doc.zip' |
| @@ -158,6 +174,7 @@ class TestDdeLinks(unittest.TestCase): | @@ -158,6 +174,7 @@ class TestDdeLinks(unittest.TestCase): | ||
| 158 | self.assertEqual(len(self.get_dde_from_output(output)), 0, | 174 | self.assertEqual(len(self.get_dde_from_output(output)), 0, |
| 159 | msg='Found dde links in output of ' + filename) | 175 | msg='Found dde links in output of ' + filename) |
| 160 | 176 | ||
| 177 | + @unittest.skipIf(*SKIP_PYPY_WIN) | ||
| 161 | def test_with_dde_utf16le(self): | 178 | def test_with_dde_utf16le(self): |
| 162 | """ check that dde links appear on stdout """ | 179 | """ check that dde links appear on stdout """ |
| 163 | filename = 'dde-test-from-office2013-utf_16le-korean.doc.zip' | 180 | filename = 'dde-test-from-office2013-utf_16le-korean.doc.zip' |
| @@ -179,6 +196,7 @@ class TestDdeLinks(unittest.TestCase): | @@ -179,6 +196,7 @@ class TestDdeLinks(unittest.TestCase): | ||
| 179 | msg='unexpected output for dde-test.{0}: {1}' | 196 | msg='unexpected output for dde-test.{0}: {1}' |
| 180 | .format(extn, output)) | 197 | .format(extn, output)) |
| 181 | 198 | ||
| 199 | + @unittest.skipIf(*SKIP_PYPY_WIN) | ||
| 182 | def test_xml(self): | 200 | def test_xml(self): |
| 183 | """ check that dde in xml from word / excel is found """ | 201 | """ check that dde in xml from word / excel is found """ |
| 184 | for filename in ('dde-in-excel2003.xml', | 202 | for filename in ('dde-in-excel2003.xml', |
tests/test_utils/testdata_reader.py
| @@ -100,6 +100,9 @@ def decrypt_sample(relpath): | @@ -100,6 +100,9 @@ def decrypt_sample(relpath): | ||
| 100 | 100 | ||
| 101 | Code based on test_encoding_handler.temp_file(). | 101 | Code based on test_encoding_handler.temp_file(). |
| 102 | 102 | ||
| 103 | + Note: this causes problems if running with PyPy on Windows. The `unlink` | ||
| 104 | + fails because the file is "still being used by another process". | ||
| 105 | + | ||
| 103 | :param relpath: path inside `DATA_BASE_DIR`, should end in '.zip' | 106 | :param relpath: path inside `DATA_BASE_DIR`, should end in '.zip' |
| 104 | :return: absolute path name to decrypted sample. | 107 | :return: absolute path name to decrypted sample. |
| 105 | """ | 108 | """ |