# The following exec statement (or something like it) is needed to
# prevent SyntaxError on Python < 2.5. Even though this is a test,
# SyntaxErrors are not acceptable; on Debian systems, they block
# byte-compilation during install and thus cause the package to fail
# to install.

import sys
if sys.version_info[:2] >= (2, 5):
    exec """
from __future__ import with_statement
import platform

from numpy.core import *
from numpy.random import rand, randint
from numpy.testing import *


class TestErrstate(TestCase):
    @dec.skipif(platform.machine() == "armv5tel", "See gh-413.")
    def test_invalid(self):
        with errstate(all='raise', under='ignore'):
            a = -arange(3)
            # This should work
            with errstate(invalid='ignore'):
                sqrt(a)
            # While this should fail!
            try:
                sqrt(a)
            except FloatingPointError:
                pass
            else:
                self.fail("Did not raise an invalid error")

    def test_divide(self):
        with errstate(all='raise', under='ignore'):
            a = -arange(3)
            # This should work
            with errstate(divide='ignore'):
                a // 0
            # While this should fail!
            try:
                a // 0
            except FloatingPointError:
                pass
            else:
                self.fail("Did not raise divide by zero error")

    def test_errcall(self):
        def foo(*args):
            print(args)
        olderrcall = geterrcall()
        with errstate(call=foo):
            assert_(geterrcall() is foo, 'call is not foo')
            with errstate(call=None):
                assert_(geterrcall() is None, 'call is not None')
        assert_(geterrcall() is olderrcall, 'call is not olderrcall')

"""

if __name__ == "__main__":
    run_module_suite()

@@ -1,492 +1,106 @@
-# The following exec statement (or something like it) is needed to%0A# prevent SyntaxError on Python %3C 2.5. Even though this is a test,%0A# SyntaxErrors are not acceptable; on Debian systems, they block%0A# byte-compilation during install and thus cause the package to fail%0A# to install.%0A%0Aimport sys%0Aif sys.version_info%5B:2%5D %3E= (2, 5):%0A    exec %22%22%22%0Afrom __future__ import with_statement%0Aimport platform%0A%0Afrom numpy.core import *%0Afrom numpy.random import rand, randint%0Afrom numpy.testing import *
+import platform%0A%0Aimport numpy as np%0Afrom numpy.testing import TestCase, assert_, run_module_suite, dec
 %0A%0A%0Ac
@@ -226,32 +226,35 @@
 ):%0A        with 
+np.
 errstate(all='ra
@@ -285,32 +285,35 @@
            a = -
+np.
 arange(3)%0A      
@@ -346,32 +346,35 @@
            with 
+np.
 errstate(invalid
@@ -393,32 +393,35 @@
                 
+np.
 sqrt(a)%0A        
@@ -483,16 +483,19 @@
         
+np.
 sqrt(a)%0A
@@ -665,32 +665,35 @@
 ):%0A        with 
+np.
 errstate(all='ra
@@ -732,16 +732,19 @@
    a = -
+np.
 arange(3
@@ -785,32 +785,35 @@
            with 
+np.
 errstate(divide=
@@ -1164,16 +1164,19 @@
 rcall = 
+np.
 geterrca
@@ -1185,32 +1185,35 @@
 ()%0A        with 
+np.
 errstate(call=fo
@@ -1228,32 +1228,35 @@
         assert_(
+np.
 geterrcall() is 
@@ -1296,16 +1296,19 @@
    with 
+np.
 errstate
@@ -1336,32 +1336,35 @@
         assert_(
+np.
 geterrcall() is 
@@ -1405,16 +1405,19 @@
 assert_(
+np.
 geterrca
@@ -1467,12 +1467,8 @@
 ')%0A%0A
-%22%22%22%0A
 %0Aif 

remove painful to look at exec statement from np.errstate test.