[svn r63580] * removing usage of py.magic.patch
* removing obsolete greenlet.py --HG-- branch : trunk
This commit is contained in:
parent
245da9de19
commit
cca19f1183
|
@ -25,8 +25,8 @@ version = "1.0.0b1"
|
|||
|
||||
initpkg(__name__,
|
||||
description = "pylib and py.test: agile development and test support library",
|
||||
revision = int('$LastChangedRevision: 63360 $'.split(':')[1][:-1]),
|
||||
lastchangedate = '$LastChangedDate: 2009-03-26 13:51:47 +0100 (Thu, 26 Mar 2009) $',
|
||||
revision = int('$LastChangedRevision: 63580 $'.split(':')[1][:-1]),
|
||||
lastchangedate = '$LastChangedDate: 2009-04-03 19:45:25 +0200 (Fri, 03 Apr 2009) $',
|
||||
version = version,
|
||||
url = "http://pylib.org",
|
||||
download_url = "http://codespeak.net/py/%s/download.html" % version,
|
||||
|
@ -117,7 +117,6 @@ initpkg(__name__,
|
|||
|
||||
# some nice slightly magic APIs
|
||||
'magic.__doc__' : ('./magic/__init__.py', '__doc__'),
|
||||
'magic.greenlet' : ('./magic/greenlet.py', 'greenlet'),
|
||||
'magic.invoke' : ('./magic/invoke.py', 'invoke'),
|
||||
'magic.revoke' : ('./magic/invoke.py', 'revoke'),
|
||||
'magic.patch' : ('./magic/patch.py', 'patch'),
|
||||
|
|
|
@ -6,22 +6,15 @@ def skip_win32():
|
|||
if sys.platform == 'win32':
|
||||
py.test.skip('Not relevant on win32')
|
||||
|
||||
def test_terminalwriter_computes_width():
|
||||
py.magic.patch(terminalwriter, 'get_terminal_width', lambda: 42)
|
||||
try:
|
||||
tw = py.io.TerminalWriter()
|
||||
assert tw.fullwidth == 42
|
||||
finally:
|
||||
py.magic.revert(terminalwriter, 'get_terminal_width')
|
||||
def test_terminalwriter_computes_width(monkeypatch):
|
||||
monkeypatch.setattr(terminalwriter, 'get_terminal_width', lambda: 42)
|
||||
tw = py.io.TerminalWriter()
|
||||
assert tw.fullwidth == 42
|
||||
|
||||
def test_terminalwriter_defaultwidth_80():
|
||||
py.magic.patch(terminalwriter, '_getdimensions', lambda: 0/0)
|
||||
try:
|
||||
tw = py.io.TerminalWriter()
|
||||
assert tw.fullwidth == int(os.environ.get('COLUMNS', 80)) -1
|
||||
finally:
|
||||
py.magic.revert(terminalwriter, '_getdimensions')
|
||||
|
||||
def test_terminalwriter_defaultwidth_80(monkeypatch):
|
||||
monkeypatch.setattr(terminalwriter, '_getdimensions', lambda: 0/0)
|
||||
tw = py.io.TerminalWriter()
|
||||
assert tw.fullwidth == int(os.environ.get('COLUMNS', 80)) -1
|
||||
|
||||
def test_terminalwriter_default_instantiation():
|
||||
tw = py.io.TerminalWriter(stringio=True)
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
import sys
|
||||
if '_stackless' in sys.builtin_module_names:
|
||||
# when running on top of a pypy with stackless support
|
||||
from _stackless import greenlet
|
||||
elif hasattr(sys, 'pypy_objspaceclass'):
|
||||
raise ImportError("Detected pypy without stackless support")
|
||||
else:
|
||||
# regular CPython
|
||||
import py
|
||||
gdir = py.path.local(py.__file__).dirpath()
|
||||
path = gdir.join('c-extension', 'greenlet', 'greenlet.c')
|
||||
greenlet = path._getpymodule().greenlet
|
|
@ -667,14 +667,11 @@ class TestCollectonly:
|
|||
!!! ValueError: 0 !!!
|
||||
""")
|
||||
|
||||
def test_repr_python_version():
|
||||
py.magic.patch(sys, 'version_info', (2, 5, 1, 'final', 0))
|
||||
try:
|
||||
assert repr_pythonversion() == "2.5.1-final-0"
|
||||
py.std.sys.version_info = x = (2,3)
|
||||
assert repr_pythonversion() == str(x)
|
||||
finally:
|
||||
py.magic.revert(sys, 'version_info')
|
||||
def test_repr_python_version(monkeypatch):
|
||||
monkeypatch.setattr(sys, 'version_info', (2, 5, 1, 'final', 0))
|
||||
assert repr_pythonversion() == "2.5.1-final-0"
|
||||
py.std.sys.version_info = x = (2,3)
|
||||
assert repr_pythonversion() == str(x)
|
||||
|
||||
def test_generic(plugintester):
|
||||
plugintester.apicheck(TerminalPlugin)
|
||||
|
|
|
@ -21,22 +21,16 @@ class TestModule:
|
|||
py.test.raises(SyntaxError, modcol.collect)
|
||||
py.test.raises(SyntaxError, modcol.run)
|
||||
|
||||
def test_module_assertion_setup(self, testdir):
|
||||
def test_module_assertion_setup(self, testdir, monkeypatch):
|
||||
modcol = testdir.getmodulecol("pass")
|
||||
from py.__.magic import assertion
|
||||
l = []
|
||||
py.magic.patch(assertion, "invoke", lambda: l.append(None))
|
||||
try:
|
||||
modcol.setup()
|
||||
finally:
|
||||
py.magic.revert(assertion, "invoke")
|
||||
monkeypatch.setattr(assertion, "invoke", lambda: l.append(None))
|
||||
modcol.setup()
|
||||
x = l.pop()
|
||||
assert x is None
|
||||
py.magic.patch(assertion, "revoke", lambda: l.append(None))
|
||||
try:
|
||||
modcol.teardown()
|
||||
finally:
|
||||
py.magic.revert(assertion, "revoke")
|
||||
monkeypatch.setattr(assertion, "revoke", lambda: l.append(None))
|
||||
modcol.teardown()
|
||||
x = l.pop()
|
||||
assert x is None
|
||||
|
||||
|
|
|
@ -135,7 +135,8 @@ class SessionTests:
|
|||
assert skips[0].skipped
|
||||
|
||||
class TestNewSession(SessionTests):
|
||||
def test_pdb_run(self, testdir):
|
||||
def test_pdb_run(self, testdir, monkeypatch):
|
||||
import py.__.test.custompdb
|
||||
tfile = testdir.makepyfile("""
|
||||
def test_usepdb():
|
||||
assert 0
|
||||
|
@ -143,11 +144,8 @@ class TestNewSession(SessionTests):
|
|||
l = []
|
||||
def mypdb(*args):
|
||||
l.append(args)
|
||||
py.magic.patch(py.__.test.custompdb, 'post_mortem', mypdb)
|
||||
try:
|
||||
sorter = testdir.inline_run('--pdb', tfile)
|
||||
finally:
|
||||
py.magic.revert(py.__.test.custompdb, 'post_mortem')
|
||||
monkeypatch.setattr(py.__.test.custompdb, 'post_mortem', mypdb)
|
||||
sorter = testdir.inline_run('--pdb', tfile)
|
||||
rep = sorter.getreport("test_usepdb")
|
||||
assert rep.failed
|
||||
assert len(l) == 1
|
||||
|
|
Loading…
Reference in New Issue