Skip to content

Instantly share code, notes, and snippets.

"""
Allows to test twisted applications with pytest.
Last modified: 2010-12-27 18:15:20 by ralf
Notes: twisted's asynchronous behavior may have influence on the order of test-functions
TODO:
+ credits to Ralf Schmitt See: http://twistedmatrix.com/pipermail/twisted-python/2007-February/014872.html
+ get test to work
(autoload 'ac-ropemacs-setup "auto-complete-python" "setup autocomplete with ropemacs" t)
(ac-ropemacs-require)
(setq ac-sources (append (list 'ac-source-ropemacs) ac-sources))
(ropemacs-mode 1)
#! /bin/sh
pip install --user -r /dev/stdin <<EOF
hg+http://bitbucket.org/agr/rope#egg=rope
hg+http://bitbucket.org/agr/ropemode#egg=ropemode
hg+http://bitbucket.org/agr/ropemacs#egg=ropemacs
pysmell
EOF
from gevent import spawn, event, sleep
count = 0
ev = event.Event()
def doit():
global count
ev.wait()
count += 1
diff --git a/Lib/distutils/cygwinccompiler.py b/Lib/distutils/cygwinccompiler.py
index 2ca5f80..6aa79df 100644
--- a/Lib/distutils/cygwinccompiler.py
+++ b/Lib/distutils/cygwinccompiler.py
@@ -60,6 +60,7 @@ def get_msvcr():
"""Include the appropriate MSVC runtime library if Python was built
with MSVC 7.0 or later.
"""
+ return [] # don't link with msvcr90 when using mingw64
msc_pos = sys.version.find('MSC v.')
#include <exception>
#include <iostream>
class fopen_failed: public std::exception
{
public:
const char *what() const throw() {
return "fopen failed";
}
};
@schmir
schmir / pytest-sort-bug.py
Created December 12, 2011 23:04
py.test fails with "TypeError: unorderable types: NoneType() < int()" with python 3
# py.test fails with "TypeError: unorderable types: NoneType() < int()"
import unittest
class TestJoinEmpty(unittest.TestCase):
pass
def make_test():
class Test(unittest.TestCase):
pass
Test.__name__ = "TestFoo"
@schmir
schmir / setup-gevent-dotgit
Created February 12, 2012 13:51
helper script for gevent git repository
#! /bin/sh
# helper script for gevent .git repository
# setup private ignore file and a custom script to build a versioned sdist
test -e gevent/__init__.py -a -e .git || exit "run this inside the gevent git repository"
cat >.git/make-sdist <<'EOF'
#! /bin/sh -e
test -e gevent/__init__.py -a -e .git || exit "run this inside the gevent git repository"
import threading
def pytest_runtest_setup(item):
item.activeCount = threading.activeCount()
item.session._setupstate.prepare(item)
def pytest_runtest_teardown(item, nextitem):
item.session._setupstate.teardown_exact(item, nextitem)
after = threading.activeCount()
before = item.activeCount
assert after == before, "number of threads changed from %s to %s" % (before, after)
import gevent
from gevent.hub import get_hub
lst = []
def _on_async():
oldlen = len(lst)
for fun, args, kw in lst[:]:
gevent.spawn(fun, *args, **kw)
del lst[:oldlen]