pypy support for tests

Bug #1131923 reported by IAN DELANEY
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pyOpenSSL
New
Undecided
Unassigned
pyopenssl (Gentoo Linux)
Incomplete
Unknown

Bug Description

This has taken forever to figure this far. pypy does quite well with the test suite, but it falls over at
test_crypto.py && test_ssl.py.

see bug https://bugs.pypy.org/issue1406 at pypy.org.

The first one I had fixed in 10 minutes.

diff -ur pyOpenSSL-0.13.orig/OpenSSL/test/test_crypto.py pyOpenSSL-0.13/OpenSSL/test/test_crypto.py
--- OpenSSL/test/test_crypto.py 2011-09-02 23:46:13.000000000 +0800
+++ OpenSSL/test/test_crypto.py 2013-02-23 05:50:40.205773047 +0800
@@ -7,7 +7,7 @@

 from unittest import main

-import os, re
+import os, re, sys
 from subprocess import PIPE, Popen
 from datetime import datetime, timedelta

@@ -677,7 +677,10 @@
         self.assertRaises(TypeError, setattr, name, 30, "hello")
         class evil(str):
             pass
- self.assertRaises(TypeError, setattr, name, evil(), "hello")
+ if hasattr(sys, 'pypy_version_info'):
+ self.assertRaises(AttributeError, setattr, name, evil(), "hello")
+ else:
+ self.assertRaises(TypeError, setattr, name, evil(), "hello")

     def test_setInvalidAttribute(self):

The second one brought me here for you maintainers to polish off. Try as I may I could NOT find the source of the setting of TypeError as the exception error 'type' or whatever. Instead I have made the test pass by following the error msg from the pypy run which was NOT the intended method. However, it gives you food for thought.

    try:
        memoryview
    except NameError:
        "cannot test sending memoryview without memoryview"
    else:
        def test_short_memoryview(self):
            """
            When passed a memoryview onto a small number of bytes,
            L{Connection.send} transmits all of them and returns the number of
            bytes sent.
            """
            server, client = self._loopback()
            count = server.send(buffer(b('xy')))
            self.assertEquals(count, 2)
            self.assertEquals(client.recv(2), b('xy'))

    try:
        memoryview
    except NameError:
        "cannot test sending memoryview without memoryview"
    else:
        def test_short_memoryview(self):
            """
            When passed a memoryview onto a small number of bytes,
            L{Connection.sendall} transmits all of them.
            """
            server, client = self._loopback()
            server.sendall(buffer(b('x')))
            self.assertEquals(client.recv(1), b('x'))

I can't decipher what memoryview is supposed to be. This makes it appear a circular referencing, but maybe it's designed and defined somewhere else all together, too hard for me.

The patch substitutes AttributeError for TypeError and I've spent more than long enough trying to do the same for test_ssl.py and I can only figure that's not the way to do it, don't know.
I know a buffer is an allocated bit of memory from C programming, but as for a memoryview I am guessing it's a pyopensll concoction or creation. These test just require these tweaks and I can add pypy support to pyopenssl in portage, once I get a formal fix from you here.

Changed in pyopenssl (Gentoo Linux):
status: Unknown → Incomplete
Revision history for this message
Matěj Cepl (mcepl) wrote :

> I know a buffer is an allocated bit of memory from C programming, but as for a memoryview
> I am guessing it's a pyopensll concoction or creation.

It is not ... http://docs.python.org/2/library/stdtypes.html?highlight=memoryview#memoryview

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.