Skip to content

Instantly share code, notes, and snippets.

View vsajip's full-sized avatar

Vinay Sajip vsajip

View GitHub Profile
@vsajip
vsajip / easy_servers.py
Created April 27, 2011 20:41
Easy to use socket servers for testing
# Copyright (C) 2011 Vinay Sajip. All rights reserved.
# Encapsulate socket servers into an easy-to-use package
try: # Python 2.X
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from SocketServer import ThreadingUDPServer, DatagramRequestHandler, \
ThreadingTCPServer, StreamRequestHandler
except ImportError: # Python 3.X
from http.server import HTTPServer, BaseHTTPRequestHandler
from socketserver import ThreadingUDPServer, DatagramRequestHandler, \
@vsajip
vsajip / sstest.py
Created April 30, 2011 15:21
Test SMTP server for unit testing
import asynchat
import asyncore
import errno
import logging
import logging.handlers
import smtpd
import socket
import sys
import threading
@vsajip
vsajip / test.log
Created May 4, 2011 21:15
Test results for wtforms-xhtml
(wtforms)vinay@eta-natty:~/tools/wtforms-xhtml/tests$ python runtests.py ext_xhtml
........................................................................................................................................
----------------------------------------------------------------------
Ran 136 tests in 0.035s
OK
@vsajip
vsajip / smtp_test.py
Created May 9, 2011 23:41
SMTP test code
#!/usr/bin/env python
import asynchat
import asyncore
from email.utils import formatdate
import errno
import smtpd
import smtplib
import socket
import threading
import unittest
@vsajip
vsajip / babel_dates.py
Created May 24, 2011 10:53
Enhanced parse_date for Babel
# Copyright (C) 2011 Vinay Sajip. All rights reserved.
# -*- coding: UTF-8 -*-
import babel.core
import babel.dates
import datetime
import re
time_locale = babel.core.default_locale('LC_TIME')
def parse_date(string, locale=time_locale, fmt=None):
running test
running egg_info
writing Babel.egg-info/PKG-INFO
writing top-level names to Babel.egg-info/top_level.txt
writing dependency_links to Babel.egg-info/dependency_links.txt
writing entry points to Babel.egg-info/entry_points.txt
reading manifest file 'Babel.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'doc/api/*.*'
warning: no files found matching 'doc/*.html'
running test
running egg_info
writing requirements to Elixir.egg-info/requires.txt
writing Elixir.egg-info/PKG-INFO
writing top-level names to Elixir.egg-info/top_level.txt
writing dependency_links to Elixir.egg-info/dependency_links.txt
reading manifest file 'Elixir.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files found matching 'release.howto'
writing manifest file 'Elixir.egg-info/SOURCES.txt'
@vsajip
vsajip / sa-0.7.diff
Created June 2, 2011 08:49
Patch for elixir r534 tests to work with SQLAlchemy 0.7
Index: tests/test_options.py
===================================================================
--- tests/test_options.py (revision 534)
+++ tests/test_options.py (working copy)
@@ -2,9 +2,15 @@
test options
"""
+from nose import SkipTest
+import sqlalchemy
test_analysis.test_regextokenizer ... ok
test_analysis.test_composition1 ... ok
test_analysis.test_composition2 ... ok
test_analysis.test_composition3 ... ok
test_analysis.test_composing_functions ... ok
test_analysis.test_shared_composition ... ok
test_analysis.test_multifilter ... ok
test_analysis.test_intraword ... ok
test_analysis.test_biword ... ok
test_analysis.test_shingles ... ok
@vsajip
vsajip / pythonv.log
Created June 13, 2011 10:59
A log of using pythonv to create a virtual environment and installing into it using pysetup3
Creating a virtual environment in a target directory ...
=============================================================================
vinay@eta-natty:~$ python3.3 -m virtualize /tmp/venv
Installing distribute .......................................................
.............................................................................
.............................................................................
.............................................................................
.....................................................done.
=============================================================================
You can add --no-dist to avoid installing Distribute, but then you can only