startling / cytoplasm

A static site generator written in python.
MIT License
13 stars 0 forks source link

The server tests don't work in Python 3. #1

Closed startling closed 12 years ago

startling commented 12 years ago

I get tons of errors, even if I use 2to3. The first server test works, but the second one gets "socket.error: [Errno 48] Address already in use " -- does the server not end in python 3 when you terminate the process?

This is the error I get when I use to 2to3ed version:

.E.E.localhost - - [26/Dec/2011 19:32:10] "GET /one.html HTTP/1.1" 200 -
FProcess Process-2:
Traceback (most recent call last):
  File "/Users/tim/.pythonbrew/pythons/Python-3.2/lib/python3.2/multiprocessing/process.py", line 259, in _bootstrap
    self.run()
  File "/Users/tim/.pythonbrew/pythons/Python-3.2/lib/python3.2/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/tim/Code/cytoplasm_dir/cytoplasm/cytoplasm/server.py", line 77, in serve
    httpd = HTTPServer(('', port), handler)
  File "/Users/tim/.pythonbrew/pythons/Python-3.2/lib/python3.2/socketserver.py", line 408, in __init__
    self.server_bind()
  File "/Users/tim/.pythonbrew/pythons/Python-3.2/lib/python3.2/http/server.py", line 128, in server_bind
    socketserver.TCPServer.server_bind(self)
  File "/Users/tim/.pythonbrew/pythons/Python-3.2/lib/python3.2/socketserver.py", line 419, in server_bind
    self.socket.bind(self.server_address)
socket.error: [Errno 48] Address already in use

After I ^c to quit that, I get a bunch more errors from nose, for failed tests. Here's a gist.

Here's a gist of 2to3's changes, just for the record.

Despite all this, cytoplasm serve appears to work perfectly under python 3. Go figure.

startling commented 12 years ago

Even if I work around the socket.error: [Errno 48] Address already in use error by making each test use a different port, I get a whole bunch more errors, so it seems deeper than at first thought. Here's a gist of the further errors.

startling commented 12 years ago

Worked around I guess with 581d4ce983 startling authored 41 minutes ago . Since this doesn't work very well at all, I may return to this sometime. Maybe I'll come up with a way to test handlers? I'm spending too much time on this right now anyway, and I have more important tests to write.