Commits

Anonymous committed 28ea216

py.test changed to pytest in all tests of util module.

  • Participants
  • Parent commits 1e5327a

Comments (0)

Files changed (10)

MoinMoin/util/_tests/test_crypto.py

 
 
 import py
-
+import pytest
 from MoinMoin.util import crypto
 
 

MoinMoin/util/_tests/test_filesys.py

 import sys, os, time
 import shutil, tempfile
 
-import py.test
 import pytest
 
 from MoinMoin.util import filesys
         self.makefile(self.dst, "dst")
         # win32-like rename does not overwrite an existing destination
         # (on posix, we emulate this behaviour)
-        py.test.raises(OSError, filesys.rename_no_overwrite, self.src, self.dst)
+        pytest.raises(OSError, filesys.rename_no_overwrite, self.src, self.dst)
 
     def test_special_rename_exists(self):
         self.makefile(self.src, "src")
         self.makefile(self.dst, "dst")
-        py.test.raises(OSError, filesys.rename_no_overwrite, self.src, self.dst, delete_old=True)
+        pytest.raises(OSError, filesys.rename_no_overwrite, self.src, self.dst, delete_old=True)
         assert not os.path.exists(self.src)
 
     def test_posix_rename_notexists(self):

MoinMoin/util/_tests/test_interwiki.py

 from __future__ import absolute_import, division
 
 import py
+import pytest
 import tempfile
 import os.path
 import shutil
         tmpdir = tempfile.mkdtemp()
 
         # test an invalid file
-        with py.test.raises(IOError):
+        with pytest.raises(IOError):
             InterWikiMap.from_file(os.path.join(tmpdir, 'void'))
 
         # test a consistent valid file
         with open(testfile, 'w') as f:
             f.write('# This is a malformed interwiki file\n'
                     'fails # ever')
-        with py.test.raises(ValueError):
+        with pytest.raises(ValueError):
             InterWikiMap.from_file(testfile)
 
         # finally destroy everything
                 dict(link1='http://link1.com/',
                      link2='http://link2.in/'))
         # test invalid strings
-        with py.test.raises(ValueError):
+        with pytest.raises(ValueError):
             InterWikiMap.from_string(u'foobarbaz')
 
 

MoinMoin/util/_tests/test_iri.py

 """
 
 
-import py.test
+import pytest
 
 from MoinMoin.util.iri import *
 

MoinMoin/util/_tests/test_lock.py

 
 import tempfile, os, time, shutil
 
-import py
+import pytest
 
 from MoinMoin.util.lock import ExclusiveLock
 
 
     def testTimeout(self):
         """ util.lock: ExclusiveLock: raise ValueError for timeout < 2.0 """
-        py.test.raises(ValueError, ExclusiveLock, self.lock_dir, timeout=1.0)
+        pytest.raises(ValueError, ExclusiveLock, self.lock_dir, timeout=1.0)
 
     def testAcquire(self):
         """ util.lock: ExclusiveLock: acquire """
         """
         lock = ExclusiveLock(self.lock_dir)
         if not lock.acquire(0.1):
-            py.test.skip("can't acquire lock")
+            pytest.skip("can't acquire lock")
         lock.release()
         assert lock.acquire(0.1)
 
         """ util.lock: ExclusiveLock: isLocked """
         lock = ExclusiveLock(self.lock_dir)
         if not lock.acquire(0.1):
-            py.test.skip("can't acquire lock")
+            pytest.skip("can't acquire lock")
         assert lock.isLocked()
         lock.release()
         assert not lock.isLocked()
         """ util.lock: ExclusiveLock: exists """
         lock = ExclusiveLock(self.lock_dir)
         if not lock.acquire(0.1):
-            py.test.skip("can't acquire lock")
+            pytest.skip("can't acquire lock")
         assert lock.exists()
 
     def testIsExpired(self):
         timeout = 2.0
         lock = ExclusiveLock(self.lock_dir, timeout=timeout)
         if not lock.acquire(0.1):
-            py.test.skip("can't acquire lock")
+            pytest.skip("can't acquire lock")
         assert not lock.isExpired()
         time.sleep(timeout)
         assert lock.isExpired()
         timeout = 2.0
         lock = ExclusiveLock(self.lock_dir, timeout=timeout)
         if not lock.acquire(0.1):
-            py.test.skip("can't acquire lock")
+            pytest.skip("can't acquire lock")
         assert not lock.expire()
         time.sleep(timeout)
         assert lock.expire()
         first = ExclusiveLock(self.lock_dir)
         second = ExclusiveLock(self.lock_dir)
         if not first.acquire(0.1):
-            py.test.skip("can't acquire lock")
+            pytest.skip("can't acquire lock")
         assert not second.acquire(0.1)
 
     def testAcquireAfterTimeout(self):
         first = ExclusiveLock(self.lock_dir, timeout)
         second = ExclusiveLock(self.lock_dir, timeout)
         if not first.acquire(0.1):
-            py.test.skip("can't acquire lock")
+            pytest.skip("can't acquire lock")
         if second.acquire(0.1):
-            py.test.skip("first lock is not exclusive")
+            pytest.skip("first lock is not exclusive")
         # Second lock should be acquired after timeout
         assert second.acquire(timeout + 0.2)
 

MoinMoin/util/_tests/test_mime.py

 """
 
 
-import py.test
+import pytest
 
 from MoinMoin.util.mime import *
 

MoinMoin/util/_tests/test_paramparser.py

         result = paramparser.UnitArgument('7mm', float, ['%', 'mm'])
         assert result.get_default() ==  (7.0, 'mm')
         assert result.parse_argument('8%') == (8.0, '%')
-        py.test.raises(ValueError, result.parse_argument,  u'7m')
-        py.test.raises(ValueError, result.parse_argument,  u'7')
-        py.test.raises(ValueError, result.parse_argument,  u'mm')
+        pytest.raises(ValueError, result.parse_argument,  u'7m')
+        pytest.raises(ValueError, result.parse_argument,  u'7')
+        pytest.raises(ValueError, result.parse_argument,  u'mm')
 
     def testExtendedParser(self):
         tests = [
         ]
 
         def _check(args, sep, kwsep, err):
-            py.test.raises(err,
+            pytest.raises(err,
                            paramparser.parse_quoted_separated_ext,
                            args, sep, kwsep,
                            brackets=(u'<>', u'()'))
 
     def testGetBooleanRaising(self):
         # wrong default type
-        py.test.raises(AssertionError, paramparser.get_bool, None, None, 42)
+        pytest.raises(AssertionError, paramparser.get_bool, None, None, 42)
 
         # anything except None or unicode raises TypeError
-        py.test.raises(TypeError, paramparser.get_bool, True)
-        py.test.raises(TypeError, paramparser.get_bool, 42)
-        py.test.raises(TypeError, paramparser.get_bool, 42.0)
-        py.test.raises(TypeError, paramparser.get_bool, '')
-        py.test.raises(TypeError, paramparser.get_bool, tuple())
-        py.test.raises(TypeError, paramparser.get_bool, [])
-        py.test.raises(TypeError, paramparser.get_bool, {})
+        pytest.raises(TypeError, paramparser.get_bool, True)
+        pytest.raises(TypeError, paramparser.get_bool, 42)
+        pytest.raises(TypeError, paramparser.get_bool, 42.0)
+        pytest.raises(TypeError, paramparser.get_bool, '')
+        pytest.raises(TypeError, paramparser.get_bool, tuple())
+        pytest.raises(TypeError, paramparser.get_bool, [])
+        pytest.raises(TypeError, paramparser.get_bool, {})
 
         # any value not convertable to boolean raises ValueError
-        py.test.raises(ValueError, paramparser.get_bool, u'')
-        py.test.raises(ValueError, paramparser.get_bool, u'42')
-        py.test.raises(ValueError, paramparser.get_bool, u'wrong')
-        py.test.raises(ValueError, paramparser.get_bool, u'"True"') # must not be quoted!
+        pytest.raises(ValueError, paramparser.get_bool, u'')
+        pytest.raises(ValueError, paramparser.get_bool, u'42')
+        pytest.raises(ValueError, paramparser.get_bool, u'wrong')
+        pytest.raises(ValueError, paramparser.get_bool, u'"True"') # must not be quoted!
 
     def testGetInt(self):
         tests = [
 
     def testGetIntRaising(self):
         # wrong default type
-        py.test.raises(AssertionError, paramparser.get_int, None, None, 42.23)
+        pytest.raises(AssertionError, paramparser.get_int, None, None, 42.23)
 
         # anything except None or unicode raises TypeError
-        py.test.raises(TypeError, paramparser.get_int, True)
-        py.test.raises(TypeError, paramparser.get_int, 42)
-        py.test.raises(TypeError, paramparser.get_int, 42.0)
-        py.test.raises(TypeError, paramparser.get_int, '')
-        py.test.raises(TypeError, paramparser.get_int, tuple())
-        py.test.raises(TypeError, paramparser.get_int, [])
-        py.test.raises(TypeError, paramparser.get_int, {})
+        pytest.raises(TypeError, paramparser.get_int, True)
+        pytest.raises(TypeError, paramparser.get_int, 42)
+        pytest.raises(TypeError, paramparser.get_int, 42.0)
+        pytest.raises(TypeError, paramparser.get_int, '')
+        pytest.raises(TypeError, paramparser.get_int, tuple())
+        pytest.raises(TypeError, paramparser.get_int, [])
+        pytest.raises(TypeError, paramparser.get_int, {})
 
         # any value not convertable to int raises ValueError
-        py.test.raises(ValueError, paramparser.get_int, u'')
-        py.test.raises(ValueError, paramparser.get_int, u'23.42')
-        py.test.raises(ValueError, paramparser.get_int, u'wrong')
-        py.test.raises(ValueError, paramparser.get_int, u'"4711"') # must not be quoted!
+        pytest.raises(ValueError, paramparser.get_int, u'')
+        pytest.raises(ValueError, paramparser.get_int, u'23.42')
+        pytest.raises(ValueError, paramparser.get_int, u'wrong')
+        pytest.raises(ValueError, paramparser.get_int, u'"4711"') # must not be quoted!
 
     def testGetFloat(self):
         tests = [
 
     def testGetFloatRaising(self):
         # wrong default type
-        py.test.raises(AssertionError, paramparser.get_float, None, None, u'42')
+        pytest.raises(AssertionError, paramparser.get_float, None, None, u'42')
 
         # anything except None or unicode raises TypeError
-        py.test.raises(TypeError, paramparser.get_float, True)
-        py.test.raises(TypeError, paramparser.get_float, 42)
-        py.test.raises(TypeError, paramparser.get_float, 42.0)
-        py.test.raises(TypeError, paramparser.get_float, '')
-        py.test.raises(TypeError, paramparser.get_float, tuple())
-        py.test.raises(TypeError, paramparser.get_float, [])
-        py.test.raises(TypeError, paramparser.get_float, {})
+        pytest.raises(TypeError, paramparser.get_float, True)
+        pytest.raises(TypeError, paramparser.get_float, 42)
+        pytest.raises(TypeError, paramparser.get_float, 42.0)
+        pytest.raises(TypeError, paramparser.get_float, '')
+        pytest.raises(TypeError, paramparser.get_float, tuple())
+        pytest.raises(TypeError, paramparser.get_float, [])
+        pytest.raises(TypeError, paramparser.get_float, {})
 
         # any value not convertable to int raises ValueError
-        py.test.raises(ValueError, paramparser.get_float, u'')
-        py.test.raises(ValueError, paramparser.get_float, u'wrong')
-        py.test.raises(ValueError, paramparser.get_float, u'"47.11"') # must not be quoted!
+        pytest.raises(ValueError, paramparser.get_float, u'')
+        pytest.raises(ValueError, paramparser.get_float, u'wrong')
+        pytest.raises(ValueError, paramparser.get_float, u'"47.11"') # must not be quoted!
 
     def testGetComplex(self):
         tests = [
 
     def testGetComplexRaising(self):
         # wrong default type
-        py.test.raises(AssertionError, paramparser.get_complex, None, None, u'42')
+        pytest.raises(AssertionError, paramparser.get_complex, None, None, u'42')
 
         # anything except None or unicode raises TypeError
-        py.test.raises(TypeError, paramparser.get_complex, True)
-        py.test.raises(TypeError, paramparser.get_complex, 42)
-        py.test.raises(TypeError, paramparser.get_complex, 42.0)
-        py.test.raises(TypeError, paramparser.get_complex, 3j)
-        py.test.raises(TypeError, paramparser.get_complex, '')
-        py.test.raises(TypeError, paramparser.get_complex, tuple())
-        py.test.raises(TypeError, paramparser.get_complex, [])
-        py.test.raises(TypeError, paramparser.get_complex, {})
+        pytest.raises(TypeError, paramparser.get_complex, True)
+        pytest.raises(TypeError, paramparser.get_complex, 42)
+        pytest.raises(TypeError, paramparser.get_complex, 42.0)
+        pytest.raises(TypeError, paramparser.get_complex, 3j)
+        pytest.raises(TypeError, paramparser.get_complex, '')
+        pytest.raises(TypeError, paramparser.get_complex, tuple())
+        pytest.raises(TypeError, paramparser.get_complex, [])
+        pytest.raises(TypeError, paramparser.get_complex, {})
 
         # any value not convertable to int raises ValueError
-        py.test.raises(ValueError, paramparser.get_complex, u'')
-        py.test.raises(ValueError, paramparser.get_complex, u'3jj')
-        py.test.raises(ValueError, paramparser.get_complex, u'3Ij')
-        py.test.raises(ValueError, paramparser.get_complex, u'3i-3i')
-        py.test.raises(ValueError, paramparser.get_complex, u'wrong')
-        py.test.raises(ValueError, paramparser.get_complex, u'"47.11"') # must not be quoted!
+        pytest.raises(ValueError, paramparser.get_complex, u'')
+        pytest.raises(ValueError, paramparser.get_complex, u'3jj')
+        pytest.raises(ValueError, paramparser.get_complex, u'3Ij')
+        pytest.raises(ValueError, paramparser.get_complex, u'3i-3i')
+        pytest.raises(ValueError, paramparser.get_complex, u'wrong')
+        pytest.raises(ValueError, paramparser.get_complex, u'"47.11"') # must not be quoted!
 
     def testGetUnicode(self):
         tests = [
 
     def testGetUnicodeRaising(self):
         # wrong default type
-        py.test.raises(AssertionError, paramparser.get_unicode, None, None, 42)
+        pytest.raises(AssertionError, paramparser.get_unicode, None, None, 42)
 
         # anything except None or unicode raises TypeError
-        py.test.raises(TypeError, paramparser.get_unicode, True)
-        py.test.raises(TypeError, paramparser.get_unicode, 42)
-        py.test.raises(TypeError, paramparser.get_unicode, 42.0)
-        py.test.raises(TypeError, paramparser.get_unicode, '')
-        py.test.raises(TypeError, paramparser.get_unicode, tuple())
-        py.test.raises(TypeError, paramparser.get_unicode, [])
-        py.test.raises(TypeError, paramparser.get_unicode, {})
+        pytest.raises(TypeError, paramparser.get_unicode, True)
+        pytest.raises(TypeError, paramparser.get_unicode, 42)
+        pytest.raises(TypeError, paramparser.get_unicode, 42.0)
+        pytest.raises(TypeError, paramparser.get_unicode, '')
+        pytest.raises(TypeError, paramparser.get_unicode, tuple())
+        pytest.raises(TypeError, paramparser.get_unicode, [])
+        pytest.raises(TypeError, paramparser.get_unicode, {})
 
 
 class TestExtensionInvoking(object):
         ief(self._test_invoke_int_None, u'i=1')
         ief(self._test_invoke_int_None, u'i=')
         ief(self._test_invoke_int_None, u'')
-        py.test.raises(ValueError, ief,
+        pytest.raises(ValueError, ief,
                        self._test_invoke_int_None, u'x')
-        py.test.raises(ValueError, ief,
+        pytest.raises(ValueError, ief,
                        self._test_invoke_int_None, u'""')
-        py.test.raises(ValueError, ief,
+        pytest.raises(ValueError, ief,
                        self._test_invoke_int_None, u'i=""')
-        py.test.raises(ValueError, ief,
+        pytest.raises(ValueError, ief,
                        _test_invoke_int_fixed, u'a=7', [7, 8])
         ief(_test_invoke_int_fixed, u'i=1', [7, 8])
-        py.test.raises(ValueError, ief,
+        pytest.raises(ValueError, ief,
                        _test_invoke_int_fixed, u'i=""', [7, 8])
         ief(_test_invoke_int_fixed, u'i=', [7, 8])
 
             ief(choicefn, u'choice=a', [7])
             ief(choicefn, u'choice=', [7])
             ief(choicefn, u'choice="a"', [7])
-            py.test.raises(ValueError, ief,
+            pytest.raises(ValueError, ief,
                            choicefn, u'x', [7])
-            py.test.raises(ValueError, ief,
+            pytest.raises(ValueError, ief,
                            choicefn, u'choice=x', [7])
 
         ief(self._test_invoke_float_None, u'i=1.4')
         ief(self._test_invoke_float_None, u'i=')
         ief(self._test_invoke_float_None, u'')
         ief(self._test_invoke_float_None, u'1.4')
-        py.test.raises(ValueError, ief,
+        pytest.raises(ValueError, ief,
                        self._test_invoke_float_None, u'x')
-        py.test.raises(ValueError, ief,
+        pytest.raises(ValueError, ief,
                        self._test_invoke_float_None, u'""')
-        py.test.raises(ValueError, ief,
+        pytest.raises(ValueError, ief,
                        self._test_invoke_float_None, u'i=""')
         ief(self._test_trailing, u'a=7, a')
         ief(self._test_trailing, u'7, a')
             [{u'7 \xc3': 'test', 'test': u'x'}])
         ief(self._test_arbitrary_kw, u'7 \xc3=test, test= x ',
             [{u'7 \xc3': 'test', 'test': u'x'}])
-        py.test.raises(ValueError, ief,
+        pytest.raises(ValueError, ief,
                        self._test_invoke_float_required, u'')
         ief(self._test_invoke_float_required, u'1.4')
         ief(self._test_invoke_float_required, u'i=1.4')
-        py.test.raises(ValueError, ief,
+        pytest.raises(ValueError, ief,
                        self._test_invoke_choice_required, u'')
         ief(self._test_invoke_choice_required, u'a')
         ief(self._test_invoke_choice_required, u'i=a')
-        py.test.raises(ValueError, ief,
+        pytest.raises(ValueError, ief,
                        self._test_invoke_float_required, u',')
 
     def testConstructors(self):
         obj = ief(TEST1, u'a=7')
         assert isinstance(obj, TEST1)
         assert obj.constructed
-        py.test.raises(ValueError, ief, TEST1, u'b')
+        pytest.raises(ValueError, ief, TEST1, u'b')
 
         obj = ief(TEST2, u'a=7')
         assert isinstance(obj, TEST1)
         assert isinstance(obj, TEST2)
         assert obj.constructed
-        py.test.raises(ValueError, ief, TEST2, u'b')
+        pytest.raises(ValueError, ief, TEST2, u'b')
 
         # old style class
         class TEST3:
         obj = ief(TEST3, u'a=7')
         assert isinstance(obj, TEST3)
         assert obj.constructed
-        py.test.raises(ValueError, ief, TEST3, u'b')
+        pytest.raises(ValueError, ief, TEST3, u'b')
 
         obj = ief(TEST4, u'a=7')
         assert isinstance(obj, TEST3)
         assert isinstance(obj, TEST4)
         assert obj.constructed
-        py.test.raises(ValueError, ief, TEST4, u'b')
+        pytest.raises(ValueError, ief, TEST4, u'b')
 
     def testFailing(self):
         ief = paramparser.invoke_extension_function
 
-        py.test.raises(TypeError, ief, hex, u'15')
-        py.test.raises(TypeError, ief, cmp, u'15')
-        py.test.raises(AttributeError, ief, unicode, u'15')
+        pytest.raises(TypeError, ief, hex, u'15')
+        pytest.raises(TypeError, ief, cmp, u'15')
+        pytest.raises(AttributeError, ief, unicode, u'15')
 
     def testAllDefault(self):
         ief = paramparser.invoke_extension_function

MoinMoin/util/_tests/test_pysupport.py

 
 import os, errno
 
-import py
 import pytest
 from flask import current_app as app
 

MoinMoin/util/_tests/test_registry.py

 """
 
 
-import py.test
+import pytest
 
 from MoinMoin.util.registry import *
 
     r.unregister(factory_all)
     assert len(r._entries) == 0
 
-    py.test.raises(ValueError, r.unregister, factory_none)
+    pytest.raises(ValueError, r.unregister, factory_none)
     assert len(r._entries) == 0
 

MoinMoin/util/_tests/test_tree.py

 """
 
 
-import py.test
+import pytest
 
 from MoinMoin.util.tree import *