Commit ca27b066a5eab4bb61bde07e7734432d2135db22

Authored by Christian Herdtweck
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.
tests/msodde/test_basic.py
... ... @@ -9,6 +9,7 @@ Ensure that
9 9 from __future__ import print_function
10 10  
11 11 import unittest
  12 +from platform import python_implementation
12 13 import sys
13 14 import os
14 15 from os.path import join, basename
... ... @@ -19,8 +20,21 @@ from tests.test_utils import call_and_capture, decrypt_sample,\
19 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 35 class TestReturnCode(unittest.TestCase):
23 36 """ check return codes and exception behaviour (not text output) """
  37 + @unittest.skipIf(*SKIP_PYPY_WIN)
24 38 def test_valid_doc(self):
25 39 """ check that a valid doc file leads to 0 exit status """
26 40 for filename in (
... ... @@ -44,6 +58,7 @@ class TestReturnCode(unittest.TestCase):
44 58 self.do_test_validity(join(BASE_DIR, 'msodde',
45 59 filename + '.docm'))
46 60  
  61 + @unittest.skipIf(*SKIP_PYPY_WIN)
47 62 def test_valid_xml(self):
48 63 """ check that xml leads to 0 exit status """
49 64 for filename in (
... ... @@ -140,6 +155,7 @@ class TestDdeLinks(unittest.TestCase):
140 155 """
141 156 return [o for o in output.splitlines()]
142 157  
  158 + @unittest.skipIf(*SKIP_PYPY_WIN)
143 159 def test_with_dde(self):
144 160 """ check that dde links appear on stdout """
145 161 filename = 'dde-test-from-office2003.doc.zip'
... ... @@ -158,6 +174,7 @@ class TestDdeLinks(unittest.TestCase):
158 174 self.assertEqual(len(self.get_dde_from_output(output)), 0,
159 175 msg='Found dde links in output of ' + filename)
160 176  
  177 + @unittest.skipIf(*SKIP_PYPY_WIN)
161 178 def test_with_dde_utf16le(self):
162 179 """ check that dde links appear on stdout """
163 180 filename = 'dde-test-from-office2013-utf_16le-korean.doc.zip'
... ... @@ -179,6 +196,7 @@ class TestDdeLinks(unittest.TestCase):
179 196 msg='unexpected output for dde-test.{0}: {1}'
180 197 .format(extn, output))
181 198  
  199 + @unittest.skipIf(*SKIP_PYPY_WIN)
182 200 def test_xml(self):
183 201 """ check that dde in xml from word / excel is found """
184 202 for filename in ('dde-in-excel2003.xml',
... ...
tests/test_utils/testdata_reader.py
... ... @@ -100,6 +100,9 @@ def decrypt_sample(relpath):
100 100  
101 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 106 :param relpath: path inside `DATA_BASE_DIR`, should end in '.zip'
104 107 :return: absolute path name to decrypted sample.
105 108 """
... ...