SF.net SVN: jython:[7231] trunk/jython/Lib/test

[email protected] Mon, 14 Mar 2011 03:06:43 +0000
Newsgroups gmane.comp.lang.jython.cvs
Message-ID <[email protected]>
Revision: 7231
          http://jython.svn.sourceforge.net/jython/?rev=7231&view=rev
Author:   pjenvey
Date:     2011-03-14 03:06:43 +0000 (Mon, 14 Mar 2011)

Log Message:
-----------
stock from CPythonLib and not needed

Removed Paths:
-------------
    trunk/jython/Lib/test/output/test_global
    trunk/jython/Lib/test/test_base64.py
    trunk/jython/Lib/test/test_contextlib.py
    trunk/jython/Lib/test/test_email.py
    trunk/jython/Lib/test/test_email_renamed.py
    trunk/jython/Lib/test/test_gettext.py
    trunk/jython/Lib/test/test_global.py
    trunk/jython/Lib/test/test_wsgiref.py

Deleted: trunk/jython/Lib/test/output/test_global
===================================================================
--- trunk/jython/Lib/test/output/test_global	2011-03-14 02:04:08 UTC (rev 7230)
+++ trunk/jython/Lib/test/output/test_global	2011-03-14 03:06:43 UTC (rev 7231)
@@ -1 +0,0 @@
-test_global

Deleted: trunk/jython/Lib/test/test_base64.py
===================================================================
--- trunk/jython/Lib/test/test_base64.py	2011-03-14 02:04:08 UTC (rev 7230)
+++ trunk/jython/Lib/test/test_base64.py	2011-03-14 03:06:43 UTC (rev 7231)
@@ -1,190 +0,0 @@
-import unittest
-from test import test_support
-import base64
-
-
-
-class LegacyBase64TestCase(unittest.TestCase):
-    def test_encodestring(self):
-        eq = self.assertEqual
-        eq(base64.encodestring("www.python.org"), "d3d3LnB5dGhvbi5vcmc=\n")
-        eq(base64.encodestring("a"), "YQ==\n")
-        eq(base64.encodestring("ab"), "YWI=\n")
-        eq(base64.encodestring("abc"), "YWJj\n")
-        eq(base64.encodestring(""), "")
-        eq(base64.encodestring("abcdefghijklmnopqrstuvwxyz"
-                               "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-                               "0123456789!@#0^&*();:<>,. []{}"),
-           "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
-           "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT"
-           "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==\n")
-
-    def test_decodestring(self):
-        eq = self.assertEqual
-        eq(base64.decodestring("d3d3LnB5dGhvbi5vcmc=\n"), "www.python.org")
-        eq(base64.decodestring("YQ==\n"), "a")
-        eq(base64.decodestring("YWI=\n"), "ab")
-        eq(base64.decodestring("YWJj\n"), "abc")
-        eq(base64.decodestring("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
-                               "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT"
-                               "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==\n"),
-           "abcdefghijklmnopqrstuvwxyz"
-           "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-           "0123456789!@#0^&*();:<>,. []{}")
-        eq(base64.decodestring(''), '')
-
-    def test_encode(self):
-        eq = self.assertEqual
-        from cStringIO import StringIO
-        infp = StringIO('abcdefghijklmnopqrstuvwxyz'
-                        'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-                        '0123456789!@#0^&*();:<>,. []{}')
-        outfp = StringIO()
-        base64.encode(infp, outfp)
-        eq(outfp.getvalue(),
-           'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE'
-           'RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT'
-           'Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==\n')
-
-    def test_decode(self):
-        from cStringIO import StringIO
-        infp = StringIO('d3d3LnB5dGhvbi5vcmc=')
-        outfp = StringIO()
-        base64.decode(infp, outfp)
-        self.assertEqual(outfp.getvalue(), 'www.python.org')
-
-
-
-class BaseXYTestCase(unittest.TestCase):
-    def test_b64encode(self):
-        eq = self.assertEqual
-        # Test default alphabet
-        eq(base64.b64encode("www.python.org"), "d3d3LnB5dGhvbi5vcmc=")
-        eq(base64.b64encode('\x00'), 'AA==')
-        eq(base64.b64encode("a"), "YQ==")
-        eq(base64.b64encode("ab"), "YWI=")
-        eq(base64.b64encode("abc"), "YWJj")
-        eq(base64.b64encode(""), "")
-        eq(base64.b64encode("abcdefghijklmnopqrstuvwxyz"
-                            "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-                            "0123456789!@#0^&*();:<>,. []{}"),
-           "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
-           "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NT"
-           "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==")
-        # Test with arbitrary alternative characters
-        eq(base64.b64encode('\xd3V\xbeo\xf7\x1d', altchars='*$'), '01a*b$cd')
-        # Test standard alphabet
-        eq(base64.standard_b64encode("www.python.org"), "d3d3LnB5dGhvbi5vcmc=")
-        eq(base64.standard_b64encode("a"), "YQ==")
-        eq(base64.standard_b64encode("ab"), "YWI=")
-        eq(base64.standard_b64encode("abc"), "YWJj")
-        eq(base64.standard_b64encode(""), "")
-        eq(base64.standard_b64encode("abcdefghijklmnopqrstuvwxyz"
-                                     "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-                                     "0123456789!@#0^&*();:<>,. []{}"),
-           "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
-           "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NT"
-           "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==")
-        # Test with 'URL safe' alternative characters
-        eq(base64.urlsafe_b64encode('\xd3V\xbeo\xf7\x1d'), '01a-b_cd')
-
-    def test_b64decode(self):
-        eq = self.assertEqual
-        eq(base64.b64decode("d3d3LnB5dGhvbi5vcmc="), "www.python.org")
-        eq(base64.b64decode('AA=='), '\x00')
-        eq(base64.b64decode("YQ=="), "a")
-        eq(base64.b64decode("YWI="), "ab")
-        eq(base64.b64decode("YWJj"), "abc")
-        eq(base64.b64decode("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
-                            "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT"
-                            "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ=="),
-           "abcdefghijklmnopqrstuvwxyz"
-           "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-           "0123456789!@#0^&*();:<>,. []{}")
-        eq(base64.b64decode(''), '')
-        # Test with arbitrary alternative characters
-        eq(base64.b64decode('01a*b$cd', altchars='*$'), '\xd3V\xbeo\xf7\x1d')
-        # Test standard alphabet
-        eq(base64.standard_b64decode("d3d3LnB5dGhvbi5vcmc="), "www.python.org")
-        eq(base64.standard_b64decode("YQ=="), "a")
-        eq(base64.standard_b64decode("YWI="), "ab")
-        eq(base64.standard_b64decode("YWJj"), "abc")
-        eq(base64.standard_b64decode(""), "")
-        eq(base64.standard_b64decode("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
-                                     "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NT"
-                                     "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ=="),
-           "abcdefghijklmnopqrstuvwxyz"
-           "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-           "0123456789!@#0^&*();:<>,. []{}")
-        # Test with 'URL safe' alternative characters
-        eq(base64.urlsafe_b64decode('01a-b_cd'), '\xd3V\xbeo\xf7\x1d')
-
-    def test_b64decode_error(self):
-        self.assertRaises(TypeError, base64.b64decode, 'abc')
-
-    def test_b32encode(self):
-        eq = self.assertEqual
-        eq(base64.b32encode(''), '')
-        eq(base64.b32encode('\x00'), 'AA======')
-        eq(base64.b32encode('a'), 'ME======')
-        eq(base64.b32encode('ab'), 'MFRA====')
-        eq(base64.b32encode('abc'), 'MFRGG===')
-        eq(base64.b32encode('abcd'), 'MFRGGZA=')
-        eq(base64.b32encode('abcde'), 'MFRGGZDF')
-
-    def test_b32decode(self):
-        eq = self.assertEqual
-        eq(base64.b32decode(''), '')
-        eq(base64.b32decode('AA======'), '\x00')
-        eq(base64.b32decode('ME======'), 'a')
-        eq(base64.b32decode('MFRA===='), 'ab')
-        eq(base64.b32decode('MFRGG==='), 'abc')
-        eq(base64.b32decode('MFRGGZA='), 'abcd')
-        eq(base64.b32decode('MFRGGZDF'), 'abcde')
-
-    def test_b32decode_casefold(self):
-        eq = self.assertEqual
-        eq(base64.b32decode('', True), '')
-        eq(base64.b32decode('ME======', True), 'a')
-        eq(base64.b32decode('MFRA====', True), 'ab')
-        eq(base64.b32decode('MFRGG===', True), 'abc')
-        eq(base64.b32decode('MFRGGZA=', True), 'abcd')
-        eq(base64.b32decode('MFRGGZDF', True), 'abcde')
-        # Lower cases
-        eq(base64.b32decode('me======', True), 'a')
-        eq(base64.b32decode('mfra====', True), 'ab')
-        eq(base64.b32decode('mfrgg===', True), 'abc')
-        eq(base64.b32decode('mfrggza=', True), 'abcd')
-        eq(base64.b32decode('mfrggzdf', True), 'abcde')
-        # Expected exceptions
-        self.assertRaises(TypeError, base64.b32decode, 'me======')
-        # Mapping zero and one
-        eq(base64.b32decode('MLO23456'), 'b\xdd\xad\xf3\xbe')
-        eq(base64.b32decode('M1023456', map01='L'), 'b\xdd\xad\xf3\xbe')
-        eq(base64.b32decode('M1023456', map01='I'), 'b\x1d\xad\xf3\xbe')
-
-    def test_b32decode_error(self):
-        self.assertRaises(TypeError, base64.b32decode, 'abc')
-        self.assertRaises(TypeError, base64.b32decode, 'ABCDEF==')
-
-    def test_b16encode(self):
-        eq = self.assertEqual
-        eq(base64.b16encode('\x01\x02\xab\xcd\xef'), '0102ABCDEF')
-        eq(base64.b16encode('\x00'), '00')
-
-    def test_b16decode(self):
-        eq = self.assertEqual
-        eq(base64.b16decode('0102ABCDEF'), '\x01\x02\xab\xcd\xef')
-        eq(base64.b16decode('00'), '\x00')
-        # Lower case is not allowed without a flag
-        self.assertRaises(TypeError, base64.b16decode, '0102abcdef')
-        # Case fold
-        eq(base64.b16decode('0102abcdef', True), '\x01\x02\xab\xcd\xef')
-
-
-
-def test_main():
-    test_support.run_unittest(__name__)
-
-if __name__ == '__main__':
-    test_main()

Deleted: trunk/jython/Lib/test/test_contextlib.py
===================================================================
--- trunk/jython/Lib/test/test_contextlib.py	2011-03-14 02:04:08 UTC (rev 7230)
+++ trunk/jython/Lib/test/test_contextlib.py	2011-03-14 03:06:43 UTC (rev 7231)
@@ -1,337 +0,0 @@
-"""Unit tests for contextlib.py, and other context managers."""
-
-import sys
-import os
-import decimal
-import tempfile
-import unittest
-import threading
-from contextlib import *  # Tests __all__
-from test import test_support
-
-class ContextManagerTestCase(unittest.TestCase):
-
-    def test_contextmanager_plain(self):
-        state = []
-        @contextmanager
-        def woohoo():
-            state.append(1)
-            yield 42
-            state.append(999)
-        with woohoo() as x:
-            self.assertEqual(state, [1])
-            self.assertEqual(x, 42)
-            state.append(x)
-        self.assertEqual(state, [1, 42, 999])
-
-    def test_contextmanager_finally(self):
-        state = []
-        @contextmanager
-        def woohoo():
-            state.append(1)
-            try:
-                yield 42
-            finally:
-                state.append(999)
-        try:
-            with woohoo() as x:
-                self.assertEqual(state, [1])
-                self.assertEqual(x, 42)
-                state.append(x)
-                raise ZeroDivisionError()
-        except ZeroDivisionError:
-            pass
-        else:
-            self.fail("Expected ZeroDivisionError")
-        self.assertEqual(state, [1, 42, 999])
-
-    def test_contextmanager_no_reraise(self):
-        @contextmanager
-        def whee():
-            yield
-        ctx = whee()
-        ctx.__enter__()
-        # Calling __exit__ should not result in an exception
-        self.failIf(ctx.__exit__(TypeError, TypeError("foo"), None))
-
-    def test_contextmanager_trap_yield_after_throw(self):
-        @contextmanager
-        def whoo():
-            try:
-                yield
-            except:
-                yield
-        ctx = whoo()
-        ctx.__enter__()
-        self.assertRaises(
-            RuntimeError, ctx.__exit__, TypeError, TypeError("foo"), None
-        )
-
-    def test_contextmanager_except(self):
-        state = []
-        @contextmanager
-        def woohoo():
-            state.append(1)
-            try:
-                yield 42
-            except ZeroDivisionError, e:
-                state.append(e.args[0])
-                self.assertEqual(state, [1, 42, 999])
-        with woohoo() as x:
-            self.assertEqual(state, [1])
-            self.assertEqual(x, 42)
-            state.append(x)
-            raise ZeroDivisionError(999)
-        self.assertEqual(state, [1, 42, 999])
-
-    def test_contextmanager_attribs(self):
-        def attribs(**kw):
-            def decorate(func):
-                for k,v in kw.items():
-                    setattr(func,k,v)
-                return func
-            return decorate
-        @contextmanager
-        @attribs(foo='bar')
-        def baz(spam):
-            """Whee!"""
-        self.assertEqual(baz.__name__,'baz')
-        self.assertEqual(baz.foo, 'bar')
-        self.assertEqual(baz.__doc__, "Whee!")
-
-class NestedTestCase(unittest.TestCase):
-
-    # XXX This needs more work
-
-    def test_nested(self):
-        @contextmanager
-        def a():
-            yield 1
-        @contextmanager
-        def b():
-            yield 2
-        @contextmanager
-        def c():
-            yield 3
-        with nested(a(), b(), c()) as (x, y, z):
-            self.assertEqual(x, 1)
-            self.assertEqual(y, 2)
-            self.assertEqual(z, 3)
-
-    def test_nested_cleanup(self):
-        state = []
-        @contextmanager
-        def a():
-            state.append(1)
-            try:
-                yield 2
-            finally:
-                state.append(3)
-        @contextmanager
-        def b():
-            state.append(4)
-            try:
-                yield 5
-            finally:
-                state.append(6)
-        try:
-            with nested(a(), b()) as (x, y):
-                state.append(x)
-                state.append(y)
-                1 // 0
-        except ZeroDivisionError:
-            self.assertEqual(state, [1, 4, 2, 5, 6, 3])
-        else:
-            self.fail("Didn't raise ZeroDivisionError")
-
-    def test_nested_right_exception(self):
-        state = []
-        @contextmanager
-        def a():
-            yield 1
-        class b(object):
-            def __enter__(self):
-                return 2
-            def __exit__(self, *exc_info):
-                try:
-                    raise Exception()
-                except:
-                    pass
-        try:
-            with nested(a(), b()) as (x, y):
-                1 // 0
-        except ZeroDivisionError:
-            self.assertEqual((x, y), (1, 2))
-        except Exception:
-            self.fail("Reraised wrong exception")
-        else:
-            self.fail("Didn't raise ZeroDivisionError")
-
-    def test_nested_b_swallows(self):
-        @contextmanager
-        def a():
-            yield
-        @contextmanager
-        def b():
-            try:
-                yield
-            except:
-                # Swallow the exception
-                pass
-        try:
-            with nested(a(), b()):
-                1 // 0
-        except ZeroDivisionError:
-            self.fail("Didn't swallow ZeroDivisionError")
-
-    def test_nested_break(self):
-        @contextmanager
-        def a():
-            yield
-        state = 0
-        while True:
-            state += 1
-            with nested(a(), a()):
-                break
-            state += 10
-        self.assertEqual(state, 1)
-
-    def test_nested_continue(self):
-        @contextmanager
-        def a():
-            yield
-        state = 0
-        while state < 3:
-            state += 1
-            with nested(a(), a()):
-                continue
-            state += 10
-        self.assertEqual(state, 3)
-
-    def test_nested_return(self):
-        @contextmanager
-        def a():
-            try:
-                yield
-            except:
-                pass
-        def foo():
-            with nested(a(), a()):
-                return 1
-            return 10
-        self.assertEqual(foo(), 1)
-
-class ClosingTestCase(unittest.TestCase):
-
-    # XXX This needs more work
-
-    def test_closing(self):
-        state = []
-        class C:
-            def close(self):
-                state.append(1)
-        x = C()
-        self.assertEqual(state, [])
-        with closing(x) as y:
-            self.assertEqual(x, y)
-        self.assertEqual(state, [1])
-
-    def test_closing_error(self):
-        state = []
-        class C:
-            def close(self):
-                state.append(1)
-        x = C()
-        self.assertEqual(state, [])
-        try:
-            with closing(x) as y:
-                self.assertEqual(x, y)
-                1 // 0
-        except ZeroDivisionError:
-            self.assertEqual(state, [1])
-        else:
-            self.fail("Didn't raise ZeroDivisionError")
-
-class FileContextTestCase(unittest.TestCase):
-
-    def testWithOpen(self):
-        tfn = tempfile.mktemp()
-        try:
-            f = None
-            with open(tfn, "w") as f:
-                self.failIf(f.closed)
-                f.write("Booh\n")
-            self.failUnless(f.closed)
-            f = None
-            try:
-                with open(tfn, "r") as f:
-                    self.failIf(f.closed)
-                    self.assertEqual(f.read(), "Booh\n")
-                    1 // 0
-            except ZeroDivisionError:
-                self.failUnless(f.closed)
-            else:
-                self.fail("Didn't raise ZeroDivisionError")
-        finally:
-            try:
-                os.remove(tfn)
-            except os.error:
-                pass
-
-class LockContextTestCase(unittest.TestCase):
-
-    def boilerPlate(self, lock, locked):
-        self.failIf(locked())
-        with lock:
-            self.failUnless(locked())
-        self.failIf(locked())
-        try:
-            with lock:
-                self.failUnless(locked())
-                1 // 0
-        except ZeroDivisionError:
-            self.failIf(locked())
-        else:
-            self.fail("Didn't raise ZeroDivisionError")
-
-    def testWithLock(self):
-        lock = threading.Lock()
-        self.boilerPlate(lock, lock.locked)
-
-    def testWithRLock(self):
-        lock = threading.RLock()
-        self.boilerPlate(lock, lock._is_owned)
-
-    def testWithCondition(self):
-        lock = threading.Condition()
-        def locked():
-            return lock._is_owned()
-        self.boilerPlate(lock, locked)
-
-    def testWithSemaphore(self):
-        lock = threading.Semaphore()
-        def locked():
-            if lock.acquire(False):
-                lock.release()
-                return False
-            else:
-                return True
-        self.boilerPlate(lock, locked)
-
-    def testWithBoundedSemaphore(self):
-        lock = threading.BoundedSemaphore()
-        def locked():
-            if lock.acquire(False):
-                lock.release()
-                return False
-            else:
-                return True
-        self.boilerPlate(lock, locked)
-
-# This is needed to make the test actually run under regrtest.py!
-def test_main():
-    test_support.run_unittest(__name__)
-
-
-if __name__ == "__main__":
-    test_main()

Deleted: trunk/jython/Lib/test/test_email.py
===================================================================
--- trunk/jython/Lib/test/test_email.py	2011-03-14 02:04:08 UTC (rev 7230)
+++ trunk/jython/Lib/test/test_email.py	2011-03-14 03:06:43 UTC (rev 7231)
@@ -1,12 +0,0 @@
-# Copyright (C) 2001,2002 Python Software Foundation
-# email package unit tests
-
-# The specific tests now live in Lib/email/test
-from email.test.test_email import suite
-from test import test_support
-
-def test_main():
-    test_support.run_unittest(suite())
-
-if __name__ == '__main__':
-    test_main()

Deleted: trunk/jython/Lib/test/test_email_renamed.py
===================================================================
--- trunk/jython/Lib/test/test_email_renamed.py	2011-03-14 02:04:08 UTC (rev 7230)
+++ trunk/jython/Lib/test/test_email_renamed.py	2011-03-14 03:06:43 UTC (rev 7231)
@@ -1,12 +0,0 @@
-# Copyright (C) 2001-2006 Python Software Foundation
-# email package unit tests
-
-# The specific tests now live in Lib/email/test
-from email.test.test_email_renamed import suite
-from test import test_support
-
-def test_main():
-    test_support.run_unittest(suite())
-
-if __name__ == '__main__':
-    test_main()

Deleted: trunk/jython/Lib/test/test_gettext.py
===================================================================
--- trunk/jython/Lib/test/test_gettext.py	2011-03-14 02:04:08 UTC (rev 7230)
+++ trunk/jython/Lib/test/test_gettext.py	2011-03-14 03:06:43 UTC (rev 7231)
@@ -1,447 +0,0 @@
-import os
-import base64
-import shutil
-import gettext
-import unittest
-
-from test import test_support
-
-
-# TODO:
-#  - Add new tests, for example for "dgettext"
-#  - Remove dummy tests, for example testing for single and double quotes
-#    has no sense, it would have if we were testing a parser (i.e. pygettext)
-#  - Tests should have only one assert.
-
-GNU_MO_DATA = '''\
-3hIElQAAAAAGAAAAHAAAAEwAAAALAAAAfAAAAAAAAACoAAAAFQAAAKkAAAAjAAAAvwAAAKEAAADj
-AAAABwAAAIUBAAALAAAAjQEAAEUBAACZAQAAFgAAAN8CAAAeAAAA9gIAAKEAAAAVAwAABQAAALcD
-AAAJAAAAvQMAAAEAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABQAAAAYAAAACAAAAAFJh
-eW1vbmQgTHV4dXJ5IFlhY2gtdABUaGVyZSBpcyAlcyBmaWxlAFRoZXJlIGFyZSAlcyBmaWxlcwBU
-aGlzIG1vZHVsZSBwcm92aWRlcyBpbnRlcm5hdGlvbmFsaXphdGlvbiBhbmQgbG9jYWxpemF0aW9u
-CnN1cHBvcnQgZm9yIHlvdXIgUHl0aG9uIHByb2dyYW1zIGJ5IHByb3ZpZGluZyBhbiBpbnRlcmZh
-Y2UgdG8gdGhlIEdOVQpnZXR0ZXh0IG1lc3NhZ2UgY2F0YWxvZyBsaWJyYXJ5LgBtdWxsdXNrAG51
-ZGdlIG51ZGdlAFByb2plY3QtSWQtVmVyc2lvbjogMi4wClBPLVJldmlzaW9uLURhdGU6IDIwMDAt
-MDgtMjkgMTI6MTktMDQ6MDAKTGFzdC1UcmFuc2xhdG9yOiBKLiBEYXZpZCBJYsOhw7FleiA8ai1k
-YXZpZEBub29zLmZyPgpMYW5ndWFnZS1UZWFtOiBYWCA8cHl0aG9uLWRldkBweXRob24ub3JnPgpN
-SU1FLVZlcnNpb246IDEuMApDb250ZW50LVR5cGU6IHRleHQvcGxhaW47IGNoYXJzZXQ9aXNvLTg4
-NTktMQpDb250ZW50LVRyYW5zZmVyLUVuY29kaW5nOiBub25lCkdlbmVyYXRlZC1CeTogcHlnZXR0
-ZXh0LnB5IDEuMQpQbHVyYWwtRm9ybXM6IG5wbHVyYWxzPTI7IHBsdXJhbD1uIT0xOwoAVGhyb2F0
-d29iYmxlciBNYW5ncm92ZQBIYXkgJXMgZmljaGVybwBIYXkgJXMgZmljaGVyb3MAR3V2ZiB6YnFo
-eXIgY2ViaXZxcmYgdmFncmVhbmd2YmFueXZtbmd2YmEgbmFxIHlicG55dm1uZ3ZiYQpmaGNjYmVn
-IHNiZSBsYmhlIENsZ3ViYSBjZWJ0ZW56ZiBvbCBjZWJpdnF2YXQgbmEgdmFncmVzbnByIGdiIGd1
-ciBUQUgKdHJnZ3JrZyB6cmZmbnRyIHBuZ255YnQgeXZvZW5lbC4AYmFjb24Ad2luayB3aW5rAA==
-'''
-
-UMO_DATA = '''\
-3hIElQAAAAACAAAAHAAAACwAAAAFAAAAPAAAAAAAAABQAAAABAAAAFEAAAAPAQAAVgAAAAQAAABm
-AQAAAQAAAAIAAAAAAAAAAAAAAAAAAAAAYWLDngBQcm9qZWN0LUlkLVZlcnNpb246IDIuMApQTy1S
-ZXZpc2lvbi1EYXRlOiAyMDAzLTA0LTExIDEyOjQyLTA0MDAKTGFzdC1UcmFuc2xhdG9yOiBCYXJy
-eSBBLiBXQXJzYXcgPGJhcnJ5QHB5dGhvbi5vcmc+Ckxhbmd1YWdlLVRlYW06IFhYIDxweXRob24t
-ZGV2QHB5dGhvbi5vcmc+Ck1JTUUtVmVyc2lvbjogMS4wCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFp
-bjsgY2hhcnNldD11dGYtOApDb250ZW50LVRyYW5zZmVyLUVuY29kaW5nOiA3Yml0CkdlbmVyYXRl
-ZC1CeTogbWFudWFsbHkKAMKkeXoA
-'''
-
-MMO_DATA = '''\
-3hIElQAAAAABAAAAHAAAACQAAAADAAAALAAAAAAAAAA4AAAAeAEAADkAAAABAAAAAAAAAAAAAAAA
-UHJvamVjdC1JZC1WZXJzaW9uOiBObyBQcm9qZWN0IDAuMApQT1QtQ3JlYXRpb24tRGF0ZTogV2Vk
-IERlYyAxMSAwNzo0NDoxNSAyMDAyClBPLVJldmlzaW9uLURhdGU6IDIwMDItMDgtMTQgMDE6MTg6
-NTgrMDA6MDAKTGFzdC1UcmFuc2xhdG9yOiBKb2huIERvZSA8amRvZUBleGFtcGxlLmNvbT4KSmFu
-ZSBGb29iYXIgPGpmb29iYXJAZXhhbXBsZS5jb20+Ckxhbmd1YWdlLVRlYW06IHh4IDx4eEBleGFt
-cGxlLmNvbT4KTUlNRS1WZXJzaW9uOiAxLjAKQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluOyBjaGFy
-c2V0PWlzby04ODU5LTE1CkNvbnRlbnQtVHJhbnNmZXItRW5jb2Rpbmc6IHF1b3RlZC1wcmludGFi
-bGUKR2VuZXJhdGVkLUJ5OiBweWdldHRleHQucHkgMS4zCgA=
-'''
-
-LOCALEDIR = os.path.join('xx', 'LC_MESSAGES')
-MOFILE = os.path.join(LOCALEDIR, 'gettext.mo')
-UMOFILE = os.path.join(LOCALEDIR, 'ugettext.mo')
-MMOFILE = os.path.join(LOCALEDIR, 'metadata.mo')
-try:
-    LANG = os.environ['LANGUAGE']
-except:
-    LANG = 'en'
-
-
-class GettextBaseTest(unittest.TestCase):
-    def setUp(self):
-        if not os.path.isdir(LOCALEDIR):
-            os.makedirs(LOCALEDIR)
-        fp = open(MOFILE, 'wb')
-        fp.write(base64.decodestring(GNU_MO_DATA))
-        fp.close()
-        fp = open(UMOFILE, 'wb')
-        fp.write(base64.decodestring(UMO_DATA))
-        fp.close()
-        fp = open(MMOFILE, 'wb')
-        fp.write(base64.decodestring(MMO_DATA))
-        fp.close()
-        os.environ['LANGUAGE'] = 'xx'
-
-    def tearDown(self):
-        os.environ['LANGUAGE'] = LANG
-        shutil.rmtree(os.path.split(LOCALEDIR)[0])
-
-
-class GettextTestCase1(GettextBaseTest):
-    def setUp(self):
-        GettextBaseTest.setUp(self)
-        self.localedir = os.curdir
-        self.mofile = MOFILE
-        gettext.install('gettext', self.localedir)
-
-    def test_some_translations(self):
-        eq = self.assertEqual
-        # test some translations
-        eq(_('albatross'), 'albatross')
-        eq(_(u'mullusk'), 'bacon')
-        eq(_(r'Raymond Luxury Yach-t'), 'Throatwobbler Mangrove')
-        eq(_(ur'nudge nudge'), 'wink wink')
-
-    def test_double_quotes(self):
-        eq = self.assertEqual
-        # double quotes
-        eq(_("albatross"), 'albatross')
-        eq(_(u"mullusk"), 'bacon')
-        eq(_(r"Raymond Luxury Yach-t"), 'Throatwobbler Mangrove')
-        eq(_(ur"nudge nudge"), 'wink wink')
-
-    def test_triple_single_quotes(self):
-        eq = self.assertEqual
-        # triple single quotes
-        eq(_('''albatross'''), 'albatross')
-        eq(_(u'''mullusk'''), 'bacon')
-        eq(_(r'''Raymond Luxury Yach-t'''), 'Throatwobbler Mangrove')
-        eq(_(ur'''nudge nudge'''), 'wink wink')
-
-    def test_triple_double_quotes(self):
-        eq = self.assertEqual
-        # triple double quotes
-        eq(_("""albatross"""), 'albatross')
-        eq(_(u"""mullusk"""), 'bacon')
-        eq(_(r"""Raymond Luxury Yach-t"""), 'Throatwobbler Mangrove')
-        eq(_(ur"""nudge nudge"""), 'wink wink')
-
-    def test_multiline_strings(self):
-        eq = self.assertEqual
-        # multiline strings
-        eq(_('''This module provides internationalization and localization
-support for your Python programs by providing an interface to the GNU
-gettext message catalog library.'''),
-           '''Guvf zbqhyr cebivqrf vagreangvbanyvmngvba naq ybpnyvmngvba
-fhccbeg sbe lbhe Clguba cebtenzf ol cebivqvat na vagresnpr gb gur TAH
-trggrkg zrffntr pngnybt yvoenel.''')
-
-    def test_the_alternative_interface(self):
-        eq = self.assertEqual
-        # test the alternative interface
-        fp = open(self.mofile, 'rb')
-        t = gettext.GNUTranslations(fp)
-        fp.close()
-        # Install the translation object
-        t.install()
-        eq(_('nudge nudge'), 'wink wink')
-        # Try unicode return type
-        t.install(unicode=True)
-        eq(_('mullusk'), 'bacon')
-        # Test installation of other methods
-        import __builtin__
-        t.install(unicode=True, names=["gettext", "lgettext"])
-        eq(_, t.ugettext)
-        eq(__builtin__.gettext, t.ugettext)
-        eq(lgettext, t.lgettext)
-        del __builtin__.gettext
-        del __builtin__.lgettext
-
-
-class GettextTestCase2(GettextBaseTest):
-    def setUp(self):
-        GettextBaseTest.setUp(self)
-        self.localedir = os.curdir
-        # Set up the bindings
-        gettext.bindtextdomain('gettext', self.localedir)
-        gettext.textdomain('gettext')
-        # For convenience
-        self._ = gettext.gettext
-
-    def test_bindtextdomain(self):
-        self.assertEqual(gettext.bindtextdomain('gettext'), self.localedir)
-
-    def test_textdomain(self):
-        self.assertEqual(gettext.textdomain(), 'gettext')
-
-    def test_some_translations(self):
-        eq = self.assertEqual
-        # test some translations
-        eq(self._('albatross'), 'albatross')
-        eq(self._(u'mullusk'), 'bacon')
-        eq(self._(r'Raymond Luxury Yach-t'), 'Throatwobbler Mangrove')
-        eq(self._(ur'nudge nudge'), 'wink wink')
-
-    def test_double_quotes(self):
-        eq = self.assertEqual
-        # double quotes
-        eq(self._("albatross"), 'albatross')
-        eq(self._(u"mullusk"), 'bacon')
-        eq(self._(r"Raymond Luxury Yach-t"), 'Throatwobbler Mangrove')
-        eq(self._(ur"nudge nudge"), 'wink wink')
-
-    def test_triple_single_quotes(self):
-        eq = self.assertEqual
-        # triple single quotes
-        eq(self._('''albatross'''), 'albatross')
-        eq(self._(u'''mullusk'''), 'bacon')
-        eq(self._(r'''Raymond Luxury Yach-t'''), 'Throatwobbler Mangrove')
-        eq(self._(ur'''nudge nudge'''), 'wink wink')
-
-    def test_triple_double_quotes(self):
-        eq = self.assertEqual
-        # triple double quotes
-        eq(self._("""albatross"""), 'albatross')
-        eq(self._(u"""mullusk"""), 'bacon')
-        eq(self._(r"""Raymond Luxury Yach-t"""), 'Throatwobbler Mangrove')
-        eq(self._(ur"""nudge nudge"""), 'wink wink')
-
-    def test_multiline_strings(self):
-        eq = self.assertEqual
-        # multiline strings
-        eq(self._('''This module provides internationalization and localization
-support for your Python programs by providing an interface to the GNU
-gettext message catalog library.'''),
-           '''Guvf zbqhyr cebivqrf vagreangvbanyvmngvba naq ybpnyvmngvba
-fhccbeg sbe lbhe Clguba cebtenzf ol cebivqvat na vagresnpr gb gur TAH
-trggrkg zrffntr pngnybt yvoenel.''')
-
-
-class PluralFormsTestCase(GettextBaseTest):
-    def setUp(self):
-        GettextBaseTest.setUp(self)
-        self.mofile = MOFILE
-
-    def test_plural_forms1(self):
-        eq = self.assertEqual
-        x = gettext.ngettext('There is %s file', 'There are %s files', 1)
-        eq(x, 'Hay %s fichero')
-        x = gettext.ngettext('There is %s file', 'There are %s files', 2)
-        eq(x, 'Hay %s ficheros')
-
-    def test_plural_forms2(self):
-        eq = self.assertEqual
-        fp = open(self.mofile, 'rb')
-        t = gettext.GNUTranslations(fp)
-        fp.close()
-        x = t.ngettext('There is %s file', 'There are %s files', 1)
-        eq(x, 'Hay %s fichero')
-        x = t.ngettext('There is %s file', 'There are %s files', 2)
-        eq(x, 'Hay %s ficheros')
-
-    def test_hu(self):
-        eq = self.assertEqual
-        f = gettext.c2py('0')
-        s = ''.join([ str(f(x)) for x in range(200) ])
-        eq(s, "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
-
-    def test_de(self):
-        eq = self.assertEqual
-        f = gettext.c2py('n != 1')
-        s = ''.join([ str(f(x)) for x in range(200) ])
-        eq(s, "10111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")
-
-    def test_fr(self):
-        eq = self.assertEqual
-        f = gettext.c2py('n>1')
-        s = ''.join([ str(f(x)) for x in range(200) ])
-        eq(s, "00111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")
-
-    def test_gd(self):
-        eq = self.assertEqual
-        f = gettext.c2py('n==1 ? 0 : n==2 ? 1 : 2')
-        s = ''.join([ str(f(x)) for x in range(200) ])
-        eq(s, "20122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222")
-
-    def test_gd2(self):
-        eq = self.assertEqual
-        # Tests the combination of parentheses and "?:"
-        f = gettext.c2py('n==1 ? 0 : (n==2 ? 1 : 2)')
-        s = ''.join([ str(f(x)) for x in range(200) ])
-        eq(s, "20122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222")
-
-    def test_lt(self):
-        eq = self.assertEqual
-        f = gettext.c2py('n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2')
-        s = ''.join([ str(f(x)) for x in range(200) ])
-        eq(s, "20111111112222222222201111111120111111112011111111201111111120111111112011111111201111111120111111112011111111222222222220111111112011111111201111111120111111112011111111201111111120111111112011111111")
-
-    def test_ru(self):
-        eq = self.assertEqual
-        f = gettext.c2py('n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2')
-        s = ''.join([ str(f(x)) for x in range(200) ])
-        eq(s, "20111222222222222222201112222220111222222011122222201112222220111222222011122222201112222220111222222011122222222222222220111222222011122222201112222220111222222011122222201112222220111222222011122222")
-
-    def test_pl(self):
-        eq = self.assertEqual
-        f = gettext.c2py('n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2')
-        s = ''.join([ str(f(x)) for x in range(200) ])
-        eq(s, "20111222222222222222221112222222111222222211122222221112222222111222222211122222221112222222111222222211122222222222222222111222222211122222221112222222111222222211122222221112222222111222222211122222")
-
-    def test_sl(self):
-        eq = self.assertEqual
-        f = gettext.c2py('n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3')
-        s = ''.join([ str(f(x)) for x in range(200) ])
-        eq(s, "30122333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333012233333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333")
-
-    def test_security(self):
-        raises = self.assertRaises
-        # Test for a dangerous expression
-        raises(ValueError, gettext.c2py, "os.chmod('/etc/passwd',0777)")
-
-
-class UnicodeTranslationsTest(GettextBaseTest):
-    def setUp(self):
-        GettextBaseTest.setUp(self)
-        fp = open(UMOFILE, 'rb')
-        try:
-            self.t = gettext.GNUTranslations(fp)
-        finally:
-            fp.close()
-        self._ = self.t.ugettext
-
-    def test_unicode_msgid(self):
-        unless = self.failUnless
-        unless(isinstance(self._(''), unicode))
-        unless(isinstance(self._(u''), unicode))
-
-    def test_unicode_msgstr(self):
-        eq = self.assertEqual
-        eq(self._(u'ab\xde'), u'\xa4yz')
-
-
-class WeirdMetadataTest(GettextBaseTest):
-    def setUp(self):
-        GettextBaseTest.setUp(self)
-        fp = open(MMOFILE, 'rb')
-        try:
-            try:
-                self.t = gettext.GNUTranslations(fp)
-            except:
-                self.tearDown()
-                raise
-        finally:
-            fp.close()
-
-    def test_weird_metadata(self):
-        info = self.t.info()
-        self.assertEqual(info['last-translator'],
-           'John Doe <[email protected]>\nJane Foobar <[email protected]>')
-
-
-def test_main():
-    test_support.run_unittest(__name__)
-
-if __name__ == '__main__':
-    test_main()
-
-
-# For reference, here's the .po file used to created the GNU_MO_DATA above.
-#
-# The original version was automatically generated from the sources with
-# pygettext. Later it was manually modified to add plural forms support.
-
-'''
-# Dummy translation for the Python test_gettext.py module.
-# Copyright (C) 2001 Python Software Foundation
-# Barry Warsaw <[email protected]>, 2000.
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: 2.0\n"
-"PO-Revision-Date: 2003-04-11 14:32-0400\n"
-"Last-Translator: J. David Ibanez <[email protected]>\n"
-"Language-Team: XX <[email protected]>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=iso-8859-1\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: pygettext.py 1.1\n"
-"Plural-Forms: nplurals=2; plural=n!=1;\n"
-
-#: test_gettext.py:19 test_gettext.py:25 test_gettext.py:31 test_gettext.py:37
-#: test_gettext.py:51 test_gettext.py:80 test_gettext.py:86 test_gettext.py:92
-#: test_gettext.py:98
-msgid "nudge nudge"
-msgstr "wink wink"
-
-#: test_gettext.py:16 test_gettext.py:22 test_gettext.py:28 test_gettext.py:34
-#: test_gettext.py:77 test_gettext.py:83 test_gettext.py:89 test_gettext.py:95
-msgid "albatross"
-msgstr ""
-
-#: test_gettext.py:18 test_gettext.py:24 test_gettext.py:30 test_gettext.py:36
-#: test_gettext.py:79 test_gettext.py:85 test_gettext.py:91 test_gettext.py:97
-msgid "Raymond Luxury Yach-t"
-msgstr "Throatwobbler Mangrove"
-
-#: test_gettext.py:17 test_gettext.py:23 test_gettext.py:29 test_gettext.py:35
-#: test_gettext.py:56 test_gettext.py:78 test_gettext.py:84 test_gettext.py:90
-#: test_gettext.py:96
-msgid "mullusk"
-msgstr "bacon"
-
-#: test_gettext.py:40 test_gettext.py:101
-msgid ""
-"This module provides internationalization and localization\n"
-"support for your Python programs by providing an interface to the GNU\n"
-"gettext message catalog library."
-msgstr ""
-"Guvf zbqhyr cebivqrf vagreangvbanyvmngvba naq ybpnyvmngvba\n"
-"fhccbeg sbe lbhe Clguba cebtenzf ol cebivqvat na vagresnpr gb gur TAH\n"
-"trggrkg zrffntr pngnybt yvoenel."
-
-# Manually added, as neither pygettext nor xgettext support plural forms
-# in Python.
-msgid "There is %s file"
-msgid_plural "There are %s files"
-msgstr[0] "Hay %s fichero"
-msgstr[1] "Hay %s ficheros"
-'''
-
-# Here's the second example po file example, used to generate the UMO_DATA
-# containing utf-8 encoded Unicode strings
-
-'''
-# Dummy translation for the Python test_gettext.py module.
-# Copyright (C) 2001 Python Software Foundation
-# Barry Warsaw <[email protected]>, 2000.
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: 2.0\n"
-"PO-Revision-Date: 2003-04-11 12:42-0400\n"
-"Last-Translator: Barry A. WArsaw <[email protected]>\n"
-"Language-Team: XX <[email protected]>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=utf-8\n"
-"Content-Transfer-Encoding: 7bit\n"
-"Generated-By: manually\n"
-
-#: nofile:0
-msgid "ab\xc3\x9e"
-msgstr "\xc2\xa4yz"
-'''
-
-# Here's the third example po file, used to generate MMO_DATA
-
-'''
-msgid ""
-msgstr ""
-"Project-Id-Version: No Project 0.0\n"
-"POT-Creation-Date: Wed Dec 11 07:44:15 2002\n"
-"PO-Revision-Date: 2002-08-14 01:18:58+00:00\n"
-"Last-Translator: John Doe <[email protected]>\n"
-"Jane Foobar <[email protected]>\n"
-"Language-Team: xx <[email protected]>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=iso-8859-15\n"
-"Content-Transfer-Encoding: quoted-printable\n"
-"Generated-By: pygettext.py 1.3\n"
-'''

Deleted: trunk/jython/Lib/test/test_global.py
===================================================================
--- trunk/jython/Lib/test/test_global.py	2011-03-14 02:04:08 UTC (rev 7230)
+++ trunk/jython/Lib/test/test_global.py	2011-03-14 03:06:43 UTC (rev 7231)
@@ -1,52 +0,0 @@
-"""Verify that warnings are issued for global statements following use."""
-
-from test.test_support import run_unittest, check_syntax_error
-import unittest
-import warnings
-
-
-class GlobalTests(unittest.TestCase):
-
-    def test1(self):
-        prog_text_1 = """\
-def wrong1():
-    a = 1
-    b = 2
-    global a
-    global b
-"""
-        check_syntax_error(self, prog_text_1)
-
-    def test2(self):
-        prog_text_2 = """\
-def wrong2():
-    print x
-    global x
-"""
-        check_syntax_error(self, prog_text_2)
-
-    def test3(self):
-        prog_text_3 = """\
-def wrong3():
-    print x
-    x = 2
-    global x
-"""
-        check_syntax_error(self, prog_text_3)
-
-    def test4(self):
-        prog_text_4 = """\
-global x
-x = 2
-"""
-        # this should work
-        compile(prog_text_4, "<test string>", "exec")
-
-
-def test_main():
-    with warnings.catch_warnings():
-        warnings.filterwarnings("error", module="<test string>")
-        run_unittest(GlobalTests)
-
-if __name__ == "__main__":
-    test_main()

Deleted: trunk/jython/Lib/test/test_wsgiref.py
===================================================================
--- trunk/jython/Lib/test/test_wsgiref.py	2011-03-14 02:04:08 UTC (rev 7230)
+++ trunk/jython/Lib/test/test_wsgiref.py	2011-03-14 03:06:43 UTC (rev 7231)
@@ -1,621 +0,0 @@
-from __future__ import nested_scopes    # Backward compat for 2.1
-from unittest import TestCase
-from wsgiref.util import setup_testing_defaults
-from wsgiref.headers import Headers
-from wsgiref.handlers import BaseHandler, BaseCGIHandler
-from wsgiref import util
-from wsgiref.validate import validator
-from wsgiref.simple_server import WSGIServer, WSGIRequestHandler, demo_app
-from wsgiref.simple_server import make_server
-from StringIO import StringIO
-from SocketServer import BaseServer
-import os
-import re
-import sys
-
-from test import test_support
-
-class MockServer(WSGIServer):
-    """Non-socket HTTP server"""
-
-    def __init__(self, server_address, RequestHandlerClass):
-        BaseServer.__init__(self, server_address, RequestHandlerClass)
-        self.server_bind()
-
-    def server_bind(self):
-        host, port = self.server_address
-        self.server_name = host
-        self.server_port = port
-        self.setup_environ()
-
-
-class MockHandler(WSGIRequestHandler):
-    """Non-socket HTTP handler"""
-    def setup(self):
-        self.connection = self.request
-        self.rfile, self.wfile = self.connection
-
-    def finish(self):
-        pass
-
-
-
-
-
-def hello_app(environ,start_response):
-    start_response("200 OK", [
-        ('Content-Type','text/plain'),
-        ('Date','Mon, 05 Jun 2006 18:49:54 GMT')
-    ])
-    return ["Hello, world!"]
-
-def run_amock(app=hello_app, data="GET / HTTP/1.0\n\n"):
-    server = make_server("", 80, app, MockServer, MockHandler)
-    inp, out, err, olderr = StringIO(data), StringIO(), StringIO(), sys.stderr
-    sys.stderr = err
-
-    try:
-        server.finish_request((inp,out), ("127.0.0.1",8888))
-    finally:
-        sys.stderr = olderr
-
-    return out.getvalue(), err.getvalue()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-def compare_generic_iter(make_it,match):
-    """Utility to compare a generic 2.1/2.2+ iterator with an iterable
-
-    If running under Python 2.2+, this tests the iterator using iter()/next(),
-    as well as __getitem__.  'make_it' must be a function returning a fresh
-    iterator to be tested (since this may test the iterator twice)."""
-
-    it = make_it()
-    n = 0
-    for item in match:
-        if not it[n]==item: raise AssertionError
-        n+=1
-    try:
-        it[n]
-    except IndexError:
-        pass
-    else:
-        raise AssertionError("Too many items from __getitem__",it)
-
-    try:
-        iter, StopIteration
-    except NameError:
-        pass
-    else:
-        # Only test iter mode under 2.2+
-        it = make_it()
-        if not iter(it) is it: raise AssertionError
-        for item in match:
-            if not it.next()==item: raise AssertionError
-        try:
-            it.next()
-        except StopIteration:
-            pass
-        else:
-            raise AssertionError("Too many items from .next()",it)
-
-
-
-
-
-
-class IntegrationTests(TestCase):
-
-    def check_hello(self, out, has_length=True):
-        self.assertEqual(out,
-            "HTTP/1.0 200 OK\r\n"
-            "Server: WSGIServer/0.1 Python/"+sys.version.split()[0]+"\r\n"
-            "Content-Type: text/plain\r\n"
-            "Date: Mon, 05 Jun 2006 18:49:54 GMT\r\n" +
-            (has_length and  "Content-Length: 13\r\n" or "") +
-            "\r\n"
-            "Hello, world!"
-        )
-
-    def test_plain_hello(self):
-        out, err = run_amock()
-        self.check_hello(out)
-
-    def test_validated_hello(self):
-        out, err = run_amock(validator(hello_app))
-        # the middleware doesn't support len(), so content-length isn't there
-        self.check_hello(out, has_length=False)
-
-    def test_simple_validation_error(self):
-        def bad_app(environ,start_response):
-            start_response("200 OK", ('Content-Type','text/plain'))
-            return ["Hello, world!"]
-        out, err = run_amock(validator(bad_app))
-        self.failUnless(out.endswith(
-            "A server error occurred.  Please contact the administrator."
-        ))
-        self.assertEqual(
-            err.splitlines()[-2],
-            "AssertionError: Headers (('Content-Type', 'text/plain')) must"
-            " be of type list: <type 'tuple'>"
-        )
-
-
-
-
-
-
-class UtilityTests(TestCase):
-
-    def checkShift(self,sn_in,pi_in,part,sn_out,pi_out):
-        env = {'SCRIPT_NAME':sn_in,'PATH_INFO':pi_in}
-        util.setup_testing_defaults(env)
-        self.assertEqual(util.shift_path_info(env),part)
-        self.assertEqual(env['PATH_INFO'],pi_out)
-        self.assertEqual(env['SCRIPT_NAME'],sn_out)
-        return env
-
-    def checkDefault(self, key, value, alt=None):
-        # Check defaulting when empty
-        env = {}
-        util.setup_testing_defaults(env)
-        if isinstance(value,StringIO):
-            self.failUnless(isinstance(env[key],StringIO))
-        else:
-            self.assertEqual(env[key],value)
-
-        # Check existing value
-        env = {key:alt}
-        util.setup_testing_defaults(env)
-        self.failUnless(env[key] is alt)
-
-    def checkCrossDefault(self,key,value,**kw):
-        util.setup_testing_defaults(kw)
-        self.assertEqual(kw[key],value)
-
-    def checkAppURI(self,uri,**kw):
-        util.setup_testing_defaults(kw)
-        self.assertEqual(util.application_uri(kw),uri)
-
-    def checkReqURI(self,uri,query=1,**kw):
-        util.setup_testing_defaults(kw)
-        self.assertEqual(util.request_uri(kw,query),uri)
-
-
-
-
-
-
-    def checkFW(self,text,size,match):
-
-        def make_it(text=text,size=size):
-            return util.FileWrapper(StringIO(text),size)
-
-        compare_generic_iter(make_it,match)
-
-        it = make_it()
-        self.failIf(it.filelike.closed)
-
-        for item in it:
-            pass
-
-        self.failIf(it.filelike.closed)
-
-        it.close()
-        self.failUnless(it.filelike.closed)
-
-
-    def testSimpleShifts(self):
-        self.checkShift('','/', '', '/', '')
-        self.checkShift('','/x', 'x', '/x', '')
-        self.checkShift('/','', None, '/', '')
-        self.checkShift('/a','/x/y', 'x', '/a/x', '/y')
-        self.checkShift('/a','/x/',  'x', '/a/x', '/')
-
-
-    def testNormalizedShifts(self):
-        self.checkShift('/a/b', '/../y', '..', '/a', '/y')
-        self.checkShift('', '/../y', '..', '', '/y')
-        self.checkShift('/a/b', '//y', 'y', '/a/b/y', '')
-        self.checkShift('/a/b', '//y/', 'y', '/a/b/y', '/')
-        self.checkShift('/a/b', '/./y', 'y', '/a/b/y', '')
-        self.checkShift('/a/b', '/./y/', 'y', '/a/b/y', '/')
-        self.checkShift('/a/b', '///./..//y/.//', '..', '/a', '/y/')
-        self.checkShift('/a/b', '///', '', '/a/b/', '')
-        self.checkShift('/a/b', '/.//', '', '/a/b/', '')
-        self.checkShift('/a/b', '/x//', 'x', '/a/b/x', '/')
-        self.checkShift('/a/b', '/.', None, '/a/b', '')
-
-
-    def testDefaults(self):
-        for key, value in [
-            ('SERVER_NAME','127.0.0.1'),
-            ('SERVER_PORT', '80'),
-            ('SERVER_PROTOCOL','HTTP/1.0'),
-            ('HTTP_HOST','127.0.0.1'),
-            ('REQUEST_METHOD','GET'),
-            ('SCRIPT_NAME',''),
-            ('PATH_INFO','/'),
-            ('wsgi.version', (1,0)),
-            ('wsgi.run_once', 0),
-            ('wsgi.multithread', 0),
-            ('wsgi.multiprocess', 0),
-            ('wsgi.input', StringIO("")),
-            ('wsgi.errors', StringIO()),
-            ('wsgi.url_scheme','http'),
-        ]:
-            self.checkDefault(key,value)
-
-
-    def testCrossDefaults(self):
-        self.checkCrossDefault('HTTP_HOST',"foo.bar",SERVER_NAME="foo.bar")
-        self.checkCrossDefault('wsgi.url_scheme',"https",HTTPS="on")
-        self.checkCrossDefault('wsgi.url_scheme',"https",HTTPS="1")
-        self.checkCrossDefault('wsgi.url_scheme',"https",HTTPS="yes")
-        self.checkCrossDefault('wsgi.url_scheme',"http",HTTPS="foo")
-        self.checkCrossDefault('SERVER_PORT',"80",HTTPS="foo")
-        self.checkCrossDefault('SERVER_PORT',"443",HTTPS="on")
-
-
-    def testGuessScheme(self):
-        self.assertEqual(util.guess_scheme({}), "http")
-        self.assertEqual(util.guess_scheme({'HTTPS':"foo"}), "http")
-        self.assertEqual(util.guess_scheme({'HTTPS':"on"}), "https")
-        self.assertEqual(util.guess_scheme({'HTTPS':"yes"}), "https")
-        self.assertEqual(util.guess_scheme({'HTTPS':"1"}), "https")
-
-
-
-
-
-    def testAppURIs(self):
-        self.checkAppURI("http://127.0.0.1/")
-        self.checkAppURI("http://127.0.0.1/spam", SCRIPT_NAME="/spam")
-        self.checkAppURI("http://spam.example.com:2071/",
-            HTTP_HOST="spam.example.com:2071", SERVER_PORT="2071")
-        self.checkAppURI("http://spam.example.com/",
-            SERVER_NAME="spam.example.com")
-        self.checkAppURI("http://127.0.0.1/",
-            HTTP_HOST="127.0.0.1", SERVER_NAME="spam.example.com")
-        self.checkAppURI("https://127.0.0.1/", HTTPS="on")
-        self.checkAppURI("http://127.0.0.1:8000/", SERVER_PORT="8000",
-            HTTP_HOST=None)
-
-    def testReqURIs(self):
-        self.checkReqURI("http://127.0.0.1/")
-        self.checkReqURI("http://127.0.0.1/spam", SCRIPT_NAME="/spam")
-        self.checkReqURI("http://127.0.0.1/spammity/spam",
-            SCRIPT_NAME="/spammity", PATH_INFO="/spam")
-        self.checkReqURI("http://127.0.0.1/spammity/spam?say=ni",
-            SCRIPT_NAME="/spammity", PATH_INFO="/spam",QUERY_STRING="say=ni")
-        self.checkReqURI("http://127.0.0.1/spammity/spam", 0,
-            SCRIPT_NAME="/spammity", PATH_INFO="/spam",QUERY_STRING="say=ni")
-
-    def testFileWrapper(self):
-        self.checkFW("xyz"*50, 120, ["xyz"*40,"xyz"*10])
-
-    def testHopByHop(self):
-        for hop in (
-            "Connection Keep-Alive Proxy-Authenticate Proxy-Authorization "
-            "TE Trailers Transfer-Encoding Upgrade"
-        ).split():
-            for alt in hop, hop.title(), hop.upper(), hop.lower():
-                self.failUnless(util.is_hop_by_hop(alt))
-
-        # Not comprehensive, just a few random header names
-        for hop in (
-            "Accept Cache-Control Date Pragma Trailer Via Warning"
-        ).split():
-            for alt in hop, hop.title(), hop.upper(), hop.lower():
-                self.failIf(util.is_hop_by_hop(alt))
-
-class HeaderTests(TestCase):
-
-    def testMappingInterface(self):
-        test = [('x','y')]
-        self.assertEqual(len(Headers([])),0)
-        self.assertEqual(len(Headers(test[:])),1)
-        self.assertEqual(Headers(test[:]).keys(), ['x'])
-        self.assertEqual(Headers(test[:]).values(), ['y'])
-        self.assertEqual(Headers(test[:]).items(), test)
-        self.failIf(Headers(test).items() is test)  # must be copy!
-
-        h=Headers([])
-        del h['foo']   # should not raise an error
-
-        h['Foo'] = 'bar'
-        for m in h.has_key, h.__contains__, h.get, h.get_all, h.__getitem__:
-            self.failUnless(m('foo'))
-            self.failUnless(m('Foo'))
-            self.failUnless(m('FOO'))
-            self.failIf(m('bar'))
-
-        self.assertEqual(h['foo'],'bar')
-        h['foo'] = 'baz'
-        self.assertEqual(h['FOO'],'baz')
-        self.assertEqual(h.get_all('foo'),['baz'])
-
-        self.assertEqual(h.get("foo","whee"), "baz")
-        self.assertEqual(h.get("zoo","whee"), "whee")
-        self.assertEqual(h.setdefault("foo","whee"), "baz")
-        self.assertEqual(h.setdefault("zoo","whee"), "whee")
-        self.assertEqual(h["foo"],"baz")
-        self.assertEqual(h["zoo"],"whee")
-
-    def testRequireList(self):
-        self.assertRaises(TypeError, Headers, "foo")
-
-
-    def testExtras(self):
-        h = Headers([])
-        self.assertEqual(str(h),'\r\n')
-
-        h.add_header('foo','bar',baz="spam")
-        self.assertEqual(h['foo'], 'bar; baz="spam"')
-        self.assertEqual(str(h),'foo: bar; baz="spam"\r\n\r\n')
-
-        h.add_header('Foo','bar',cheese=None)
-        self.assertEqual(h.get_all('foo'),
-            ['bar; baz="spam"', 'bar; cheese'])
-
-        self.assertEqual(str(h),
-            'foo: bar; baz="spam"\r\n'
-            'Foo: bar; cheese\r\n'
-            '\r\n'
-        )
-
-
-class ErrorHandler(BaseCGIHandler):
-    """Simple handler subclass for testing BaseHandler"""
-
-    # BaseHandler records the OS environment at import time, but envvars
-    # might have been changed later by other tests, which trips up
-    # HandlerTests.testEnviron().
-    os_environ = dict(os.environ.items())
-
-    def __init__(self,**kw):
-        setup_testing_defaults(kw)
-        BaseCGIHandler.__init__(
-            self, StringIO(''), StringIO(), StringIO(), kw,
-            multithread=True, multiprocess=True
-        )
-
-class TestHandler(ErrorHandler):
-    """Simple handler subclass for testing BaseHandler, w/error passthru"""
-
-    def handle_error(self):
-        raise   # for testing, we want to see what's happening
-
-
-
-
-
-
-
-
-
-
-
-class HandlerTests(TestCase):
-
-    def checkEnvironAttrs(self, handler):
-        env = handler.environ
-        for attr in [
-            'version','multithread','multiprocess','run_once','file_wrapper'
-        ]:
-            if attr=='file_wrapper' and handler.wsgi_file_wrapper is None:
-                continue
-            self.assertEqual(getattr(handler,'wsgi_'+attr),env['wsgi.'+attr])
-
-    def checkOSEnviron(self,handler):
-        empty = {}; setup_testing_defaults(empty)
-        env = handler.environ
-        from os import environ
-        for k,v in environ.items():
-            if k not in empty:
-                self.assertEqual(env[k],v)
-        for k,v in empty.items():
-            self.assertTrue(k in env)
-
-    def testEnviron(self):
-        h = TestHandler(X="Y")
-        h.setup_environ()
-        self.checkEnvironAttrs(h)
-        self.checkOSEnviron(h)
-        self.assertEqual(h.environ["X"],"Y")
-
-    def testCGIEnviron(self):
-        h = BaseCGIHandler(None,None,None,{})
-        h.setup_environ()
-        for key in 'wsgi.url_scheme', 'wsgi.input', 'wsgi.errors':
-            self.assertTrue(key in h.environ)
-
-    def testScheme(self):
-        h=TestHandler(HTTPS="on"); h.setup_environ()
-        self.assertEqual(h.environ['wsgi.url_scheme'],'https')
-        h=TestHandler(); h.setup_environ()
-        self.assertEqual(h.environ['wsgi.url_scheme'],'http')
-
-
-    def testAbstractMethods(self):
-        h = BaseHandler()
-        for name in [
-            '_flush','get_stdin','get_stderr','add_cgi_vars'
-        ]:
-            self.assertRaises(NotImplementedError, getattr(h,name))
-        self.assertRaises(NotImplementedError, h._write, "test")
-
-
-    def testContentLength(self):
-        # Demo one reason iteration is better than write()...  ;)
-
-        def trivial_app1(e,s):
-            s('200 OK',[])
-            return [e['wsgi.url_scheme']]
-
-        def trivial_app2(e,s):
-            s('200 OK',[])(e['wsgi.url_scheme'])
-            return []
-
-        h = TestHandler()
-        h.run(trivial_app1)
-        self.assertEqual(h.stdout.getvalue(),
-            "Status: 200 OK\r\n"
-            "Content-Length: 4\r\n"
-            "\r\n"
-            "http")
-
-        h = TestHandler()
-        h.run(trivial_app2)
-        self.assertEqual(h.stdout.getvalue(),
-            "Status: 200 OK\r\n"
-            "\r\n"
-            "http")
-
-
-
-
-
-
-
-    def testBasicErrorOutput(self):
-
-        def non_error_app(e,s):
-            s('200 OK',[])
-            return []
-
-        def error_app(e,s):
-            raise AssertionError("This should be caught by handler")
-
-        h = ErrorHandler()
-        h.run(non_error_app)
-        self.assertEqual(h.stdout.getvalue(),
-            "Status: 200 OK\r\n"
-            "Content-Length: 0\r\n"
-            "\r\n")
-        self.assertEqual(h.stderr.getvalue(),"")
-
-        h = ErrorHandler()
-        h.run(error_app)
-        self.assertEqual(h.stdout.getvalue(),
-            "Status: %s\r\n"
-            "Content-Type: text/plain\r\n"
-            "Content-Length: %d\r\n"
-            "\r\n%s" % (h.error_status,len(h.error_body),h.error_body))
-
-        self.assertTrue("AssertionError" in h.stderr.getvalue(),
-                        "AssertionError not in stderr")
-
-    def testErrorAfterOutput(self):
-        MSG = "Some output has been sent"
-        def error_app(e,s):
-            s("200 OK",[])(MSG)
-            raise AssertionError("This should be caught by handler")
-
-        h = ErrorHandler()
-        h.run(error_app)
-        self.assertEqual(h.stdout.getvalue(),
-            "Status: 200 OK\r\n"
-            "\r\n"+MSG)
-        self.assertTrue("AssertionError" in h.stderr.getvalue(),
-                        "AssertionError not in stderr")
-
-
-    def testHeaderFormats(self):
-
-        def non_error_app(e,s):
-            s('200 OK',[])
-            return []
-
-        stdpat = (
-            r"HTTP/%s 200 OK\r\n"
-            r"Date: \w{3}, [ 0123]\d \w{3} \d{4} \d\d:\d\d:\d\d GMT\r\n"
-            r"%s" r"Content-Length: 0\r\n" r"\r\n"
-        )
-        shortpat = (
-            "Status: 200 OK\r\n" "Content-Length: 0\r\n" "\r\n"
-        )
-
-        for ssw in "FooBar/1.0", None:
-            sw = ssw and "Server: %s\r\n" % ssw or ""
-
-            for version in "1.0", "1.1":
-                for proto in "HTTP/0.9", "HTTP/1.0", "HTTP/1.1":
-
-                    h = TestHandler(SERVER_PROTOCOL=proto)
-                    h.origin_server = False
-                    h.http_version = version
-                    h.server_software = ssw
-                    h.run(non_error_app)
-                    self.assertEqual(shortpat,h.stdout.getvalue())
-
-                    h = TestHandler(SERVER_PROTOCOL=proto)
-                    h.origin_server = True
-                    h.http_version = version
-                    h.server_software = ssw
-                    h.run(non_error_app)
-                    if proto=="HTTP/0.9":
-                        self.assertEqual(h.stdout.getvalue(),"")
-                    else:
-                        self.failUnless(
-                            re.match(stdpat%(version,sw), h.stdout.getvalue()),
-                            (stdpat%(version,sw), h.stdout.getvalue())
-                        )
-
-# This epilogue is needed for compatibility with the Python 2.5 regrtest module
-
-def test_main():
-    test_support.run_unittest(__name__)
-
-if __name__ == "__main__":
-    test_main()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# the above lines intentionally left blank


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d