Author: Alexander Hesse <[email protected]>
Branch: split-rpython
Changeset: r60098:cfb2f3a5e88f
Date: 2013-01-15 20:26 +0100
http://bitbucket.org/pypy/pypy/changeset/cfb2f3a5e88f/
Log: Fixed a bunch of tests
diff --git a/rpython/rlib/test/test_rdtoa.py b/rpython/rlib/test/test_rdtoa.py
--- a/rpython/rlib/test/test_rdtoa.py
+++ b/rpython/rlib/test/test_rdtoa.py
@@ -1,3 +1,4 @@
+import py
from rpython.rlib.rdtoa import strtod, dtoa
from rpython.rlib import rfloat
@@ -6,11 +7,11 @@
assert strtod("1.1") == 1.1
assert strtod("3.47") == 3.47
assert strtod(".125") == .125
- raises(ValueError, strtod, "123A")
- raises(ValueError, strtod, "")
- raises(ValueError, strtod, " ")
- raises(ValueError, strtod, "\0")
- raises(ValueError, strtod, "3\09")
+ py.test.raises(ValueError, strtod, "123A")
+ py.test.raises(ValueError, strtod, "")
+ py.test.raises(ValueError, strtod, " ")
+ py.test.raises(ValueError, strtod, "\0")
+ py.test.raises(ValueError, strtod, "3\09")
def test_dtoa():
assert dtoa(3.47) == "3.47"
diff --git a/rpython/rlib/test/test_rmmap.py b/rpython/rlib/test/test_rmmap.py
--- a/rpython/rlib/test/test_rmmap.py
+++ b/rpython/rlib/test/test_rmmap.py
@@ -1,5 +1,5 @@
from rpython.tool.udir import udir
-import os, sys
+import os, sys, py
from rpython.rtyper.test.test_llinterp import interpret
from rpython.rlib.rarithmetic import intmask
from rpython.rlib import rmmap as mmap
@@ -255,24 +255,24 @@
def test_write_readonly(self):
if os.name == "nt":
- skip("Needs PROT_READ")
+ py.test.skip("Needs PROT_READ")
f = open(self.tmpname + "l", "w+")
f.write("foobar")
f.flush()
m = mmap.mmap(f.fileno(), 6, prot=mmap.PROT_READ)
- raises(RTypeError, m.write, "foo")
+ py.test.raises(RTypeError, m.write, "foo")
m.close()
f.close()
def test_write_without_protwrite(self):
if os.name == "nt":
- skip("Needs PROT_WRITE")
+ py.test.skip("Needs PROT_WRITE")
f = open(self.tmpname + "l2", "w+")
f.write("foobar")
f.flush()
m = mmap.mmap(f.fileno(), 6, prot=~mmap.PROT_WRITE)
- raises(RTypeError, m.write_byte, 'a')
- raises(RTypeError, m.write, "foo")
+ py.test.raises(RTypeError, m.write_byte, 'a')
+ py.test.raises(RTypeError, m.write, "foo")
m.close()
f.close()
@@ -325,7 +325,7 @@
def test_resize(self):
if ("darwin" in sys.platform) or ("freebsd" in sys.platform):
- skip("resize does not work under OSX or FreeBSD")
+ py.test.skip("resize does not work under OSX or FreeBSD")
import os
@@ -430,7 +430,7 @@
def test_windows_crasher_1(self):
if sys.platform != "win32":
- skip("Windows-only test")
+ py.test.skip("Windows-only test")
def func():
m = mmap.mmap(-1, 1000, tagname="foo")
# same tagname, but larger size
@@ -444,7 +444,7 @@
def test_windows_crasher_2(self):
if sys.platform != "win32":
- skip("Windows-only test")
+ py.test.skip("Windows-only test")
f = open(self.tmpname + "t", "w+")
f.write("foobar")
@@ -453,8 +453,8 @@
f = open(self.tmpname + "t", "r+b")
m = mmap.mmap(f.fileno(), 0)
f.close()
- raises(WindowsError, m.resize, 0)
- raises(RValueError, m.getitem, 0)
+ py.test.raises(WindowsError, m.resize, 0)
+ py.test.raises(RValueError, m.getitem, 0)
m.close()
def test_alloc_free():
diff --git a/rpython/rlib/test/test_rposix.py b/rpython/rlib/test/test_rposix.py
--- a/rpython/rlib/test/test_rposix.py
+++ b/rpython/rlib/test/test_rposix.py
@@ -134,7 +134,7 @@
def test_is_valid_fd(self):
if os.name != 'nt':
- skip('relevant for windows only')
+ py.test.skip('relevant for windows only')
assert rposix.is_valid_fd(0) == 1
fid = open(str(udir.join('validate_test.txt')), 'w')
fd = fid.fileno()
diff --git a/rpython/rlib/test/test_rsignal.py
b/rpython/rlib/test/test_rsignal.py
--- a/rpython/rlib/test/test_rsignal.py
+++ b/rpython/rlib/test/test_rsignal.py
@@ -5,7 +5,7 @@
def setup_module(mod):
if not hasattr(os, 'kill') or not hasattr(os, 'getpid'):
py.test.skip("requires os.kill() and os.getpid()")
- if not hasattr(signals, 'SIGUSR1'):
+ if not hasattr(rsignal, 'SIGUSR1'):
py.test.skip("requires SIGUSR1 in signal")
diff --git a/rpython/rlib/test/test_rstring.py
b/rpython/rlib/test/test_rstring.py
--- a/rpython/rlib/test/test_rstring.py
+++ b/rpython/rlib/test/test_rstring.py
@@ -1,4 +1,4 @@
-import sys
+import sys, py
from rpython.rlib.rstring import StringBuilder, UnicodeBuilder, split, rsplit
@@ -11,7 +11,7 @@
assert split('a|b|c|d', '|', 2) == ['a', 'b', 'c|d']
assert split('a//b//c//d', '//') == ['a', 'b', 'c', 'd']
assert split('endcase test', 'test') == ['endcase ', '']
- raises(ValueError, split, 'abc', '')
+ py.test.raises(ValueError, split, 'abc', '')
def test_rsplit():
assert rsplit("a", "a", 1) == ['', '']
@@ -21,7 +21,7 @@
assert rsplit('a|b|c|d', '|', 2) == ['a|b', 'c', 'd']
assert rsplit('a//b//c//d', '//') == ['a', 'b', 'c', 'd']
assert rsplit('endcase test', 'test') == ['endcase ', '']
- raises(ValueError, rsplit, "abc", '')
+ py.test.raises(ValueError, rsplit, "abc", '')
def test_string_builder():
s = StringBuilder()
diff --git a/rpython/rlib/test/test_runicode.py
b/rpython/rlib/test/test_runicode.py
--- a/rpython/rlib/test/test_runicode.py
+++ b/rpython/rlib/test/test_runicode.py
@@ -251,7 +251,7 @@
def test_utf8_surrogate(self):
# surrogates used to be allowed by python 2.x
- raises(UnicodeDecodeError, self.checkdecode, u"\ud800", "utf-8")
+ py.test.raises(UnicodeDecodeError, self.checkdecode, u"\ud800",
"utf-8")
def test_invalid_start_byte(self):
"""
@@ -263,7 +263,7 @@
"""
FFFD = u'\ufffd'
for byte in '\x80\xA0\x9F\xBF\xC0\xC1\xF5\xFF':
- raises(UnicodeDecodeError, self.decoder, byte, 1, None, final=True)
+ py.test.raises(UnicodeDecodeError, self.decoder, byte, 1, None,
final=True)
self.checkdecodeerror(byte, 'utf-8', 0, 1, addstuff=False,
msg='invalid start byte')
assert self.decoder(byte, 1, 'replace', final=True) == (FFFD, 1)
@@ -298,7 +298,7 @@
FFFD = u'\ufffd'
for seq in sequences:
seq = self.to_bytestring(seq)
- raises(UnicodeDecodeError, self.decoder, seq, len(seq),
+ py.test.raises(UnicodeDecodeError, self.decoder, seq, len(seq),
None, final=True)
self.checkdecodeerror(seq, 'utf-8', 0, len(seq), addstuff=False,
msg='unexpected end of data')
@@ -332,7 +332,7 @@
]
for seq, res in sequences:
seq = self.to_bytestring(seq)
- raises(UnicodeDecodeError, self.decoder, seq, len(seq),
+ py.test.raises(UnicodeDecodeError, self.decoder, seq, len(seq),
None, final=True)
self.checkdecodeerror(seq, 'utf-8', 0, 1, addstuff=False,
msg='invalid continuation byte')
@@ -404,7 +404,7 @@
]
for seq, res in sequences:
seq = self.to_bytestring(seq)
- raises(UnicodeDecodeError, self.decoder, seq, len(seq),
+ py.test.raises(UnicodeDecodeError, self.decoder, seq, len(seq),
None, final=True)
self.checkdecodeerror(seq, 'utf-8', 0, len(seq)-1, addstuff=False,
msg='invalid continuation byte')
@@ -496,7 +496,7 @@
]
for seq, res in sequences:
seq = self.to_bytestring(seq)
- raises(UnicodeDecodeError, self.decoder, seq, len(seq),
+ py.test.raises(UnicodeDecodeError, self.decoder, seq, len(seq),
None, final=True)
self.checkdecodeerror(seq, 'utf-8', 0, len(seq)-1, addstuff=False,
msg='invalid continuation byte')
@@ -626,7 +626,7 @@
for n, (seq, res) in enumerate(sequences):
decoder = self.getdecoder('utf-8')
- raises(UnicodeDecodeError, decoder, seq, len(seq), None,
final=True)
+ py.test.raises(UnicodeDecodeError, decoder, seq, len(seq), None,
final=True)
assert decoder(seq, len(seq), 'replace', final=True
) == (res, len(seq))
assert decoder(seq + 'b', len(seq) + 1, 'replace', final=True
@@ -694,7 +694,7 @@
self.checkencode(u, "utf-8")
else:
# This is not done in wide unicode builds
- raises(UnicodeEncodeError, self.checkencode, u, "utf-8")
+ py.test.raises(UnicodeEncodeError, self.checkencode, u, "utf-8")
def test_ascii_error(self):
self.checkencodeerror(u"abc\xFF\xFF\xFFcde", "ascii", 3, 6)
@@ -714,7 +714,7 @@
def test_encode_decimal(self):
encoder = self.getencoder('decimal')
assert encoder(u' 12, 34 ', 8, None) == ' 12, 34 '
- raises(UnicodeEncodeError, encoder, u' 12, \u1234 ', 7, None)
+ py.test.raises(UnicodeEncodeError, encoder, u' 12, \u1234 ', 7, None)
assert encoder(u'u\u1234', 2, 'replace') == 'u?'
class TestTranslation(object):
diff --git a/rpython/rlib/test/test_rzlib.py b/rpython/rlib/test/test_rzlib.py
--- a/rpython/rlib/test/test_rzlib.py
+++ b/rpython/rlib/test/test_rzlib.py
@@ -70,8 +70,8 @@
deflateInit() should raise ValueError when an out of bounds level is
passed to it.
"""
- raises(ValueError, rzlib.deflateInit, -2)
- raises(ValueError, rzlib.deflateInit, 10)
+ py.test.raises(ValueError, rzlib.deflateInit, -2)
+ py.test.raises(ValueError, rzlib.deflateInit, 10)
def test_deflate_init_end():
diff --git a/rpython/rlib/unicodedata/test/test_unicodedata.py
b/rpython/rlib/unicodedata/test/test_unicodedata.py
--- a/rpython/rlib/unicodedata/test/test_unicodedata.py
+++ b/rpython/rlib/unicodedata/test/test_unicodedata.py
@@ -1,3 +1,4 @@
+import py
from rpython.rlib.unicodedata import unicodedb_3_2_0, unicodedb_5_2_0
class AppTestUnicodeData:
@@ -39,8 +40,8 @@
assert unicodedata.name(unichr(code)) == name
assert unicodedata.lookup(name) == unichr(code)
# Test outside the range
- raises(ValueError, unicodedata.name, unichr(0xAC00 - 1))
- raises(ValueError, unicodedata.name, unichr(0xD7A3 + 1))
+ py.test.raises(ValueError, unicodedata.name, unichr(0xAC00 - 1))
+ py.test.raises(ValueError, unicodedata.name, unichr(0xD7A3 + 1))
def test_cjk(self):
import sys
@@ -71,7 +72,7 @@
unicodedata.name(char)
except ValueError, e:
assert e.message == 'no such name'
- raises(KeyError, unicodedata.lookup, charname)
+ py.test.raises(KeyError, unicodedata.lookup, charname)
def test_bug_1704793(self): # from CPython
import unicodedata
@@ -79,7 +80,7 @@
def test_normalize(self):
import unicodedata
- raises(TypeError, unicodedata.normalize, 'x')
+ py.test.raises(TypeError, unicodedata.normalize, 'x')
def test_normalize_wide(self):
import sys, unicodedata
@@ -128,7 +129,7 @@
def test_random_missing_chars(self):
for chr in self.nocharlist:
- raises(KeyError, unicodedb_5_2_0.name, ord(chr))
+ py.test.raises(KeyError, unicodedb_5_2_0.name, ord(chr))
def test_compare_functions(self):
import unicodedata # CPython implementation
@@ -173,7 +174,7 @@
def test_differences(self):
assert unicodedb_5_2_0.name(9187) == 'BENZENE RING WITH CIRCLE'
assert unicodedb_5_2_0.lookup('BENZENE RING WITH CIRCLE') == 9187
- raises(KeyError, unicodedb_3_2_0.lookup, 'BENZENE RING WITH CIRCLE')
- raises(KeyError, unicodedb_3_2_0.name, 9187)
+ py.test.raises(KeyError, unicodedb_3_2_0.lookup, 'BENZENE RING WITH
CIRCLE')
+ py.test.raises(KeyError, unicodedb_3_2_0.name, 9187)
diff --git a/rpython/rtyper/lltypesystem/test/test_ll2ctypes.py
b/rpython/rtyper/lltypesystem/test/test_ll2ctypes.py
--- a/rpython/rtyper/lltypesystem/test/test_ll2ctypes.py
+++ b/rpython/rtyper/lltypesystem/test/test_ll2ctypes.py
@@ -514,8 +514,8 @@
# and it can be called with the expected number of arguments
res = cmul(41, 42)
assert res == 41 * 42
- raises(TypeError, cmul, 41)
- raises(TypeError, cmul, 41, 42, 43)
+ py.test.raises(TypeError, cmul, 41)
+ py.test.raises(TypeError, cmul, 41, 42, 43)
def test_qsort(self):
CMPFUNC = lltype.FuncType([rffi.VOIDP, rffi.VOIDP], rffi.INT)
diff --git a/rpython/rtyper/module/test/test_ll_os.py
b/rpython/rtyper/module/test/test_ll_os.py
--- a/rpython/rtyper/module/test/test_ll_os.py
+++ b/rpython/rtyper/module/test/test_ll_os.py
@@ -102,7 +102,7 @@
def test_mkdir():
filename = str(udir.join('test_mkdir.dir'))
getllimpl(os.mkdir)(filename, 0)
- exc = raises(OSError, getllimpl(os.mkdir), filename, 0)
+ exc = py.test.raises(OSError, getllimpl(os.mkdir), filename, 0)
assert exc.value.errno == errno.EEXIST
if sys.platform == 'win32':
assert exc.type is WindowsError
@@ -202,7 +202,7 @@
assert fid.read() == "Hello world"
fd = os.open(fname, os.O_WRONLY|os.O_CREAT, 0777)
os.close(fd)
- raises(OSError, f, fd, 'Hello world')
+ py.test.raises(OSError, f, fd, 'Hello world')
def test_os_close():
fname = str(udir.join('os_test.txt'))
@@ -211,7 +211,7 @@
os.write(fd, 'Hello world')
f = getllimpl(os.close)
f(fd)
- raises(OSError, f, fd)
+ py.test.raises(OSError, f, fd)
def test_os_lseek():
fname = str(udir.join('os_test.txt'))
@@ -222,7 +222,7 @@
f(fd,0,0)
assert os.read(fd, 11) == 'Hello world'
os.close(fd)
- raises(OSError, f, fd, 0, 0)
+ py.test.raises(OSError, f, fd, 0, 0)
def test_os_fsync():
fname = str(udir.join('os_test.txt'))
@@ -235,13 +235,13 @@
fid = open(fname)
assert fid.read() == 'Hello world'
fid.close()
- raises(OSError, f, fd)
+ py.test.raises(OSError, f, fd)
def test_os_fdatasync():
try:
f = getllimpl(os.fdatasync)
except:
- skip('No fdatasync in os')
+ py.test.skip('No fdatasync in os')
fname = str(udir.join('os_test.txt'))
fd = os.open(fname, os.O_WRONLY|os.O_CREAT, 0777)
assert fd >= 0
@@ -250,12 +250,12 @@
fid = open(fname)
assert fid.read() == 'Hello world'
os.close(fd)
- raises(OSError, f, fd)
+ py.test.raises(OSError, f, fd)
def test_os_kill():
if not hasattr(os,'kill') or sys.platform == 'win32':
- skip('No kill in os')
+ py.test.skip('No kill in os')
f = getllimpl(os.kill)
import subprocess
import signal
@@ -272,7 +272,7 @@
try:
f = getllimpl(os.isatty)
except:
- skip('No isatty in os')
+ py.test.skip('No isatty in os')
assert f(-1) == False
diff --git a/rpython/rtyper/module/test/test_posix.py
b/rpython/rtyper/module/test/test_posix.py
--- a/rpython/rtyper/module/test/test_posix.py
+++ b/rpython/rtyper/module/test/test_posix.py
@@ -141,7 +141,7 @@
text = 'This is a test'
os.write(fi,text)
res = self.interpret(f,[fi])
- raises( OSError, os.fstat, fi)
+ py.test.raises( OSError, os.fstat, fi)
if hasattr(os, 'ftruncate'):
def test_ftruncate(self):
diff --git a/rpython/rtyper/test/test_extfunc.py
b/rpython/rtyper/test/test_extfunc.py
--- a/rpython/rtyper/test/test_extfunc.py
+++ b/rpython/rtyper/test/test_extfunc.py
@@ -1,3 +1,4 @@
+import py
from rpython.rtyper.extfunc import ExtFuncEntry, register_external,\
is_external, lazy_register
@@ -177,7 +178,7 @@
a.translator.config.translation.check_str_without_nul=True
def g(s):
return os_open(s)
- raises(Exception, a.build_types, g, [str])
+ py.test.raises(Exception, a.build_types, g, [str])
a.build_types(g, [str0]) # Does not raise
def test_list_of_str0(self):
@@ -195,7 +196,7 @@
a.translator.config.translation.check_str_without_nul=True
def g(l):
return os_execve(l)
- raises(Exception, a.build_types, g, [[str]])
+ py.test.raises(Exception, a.build_types, g, [[str]])
a.build_types(g, [[str0]]) # Does not raise
diff --git a/rpython/rtyper/test/test_rbuiltin.py
b/rpython/rtyper/test/test_rbuiltin.py
--- a/rpython/rtyper/test/test_rbuiltin.py
+++ b/rpython/rtyper/test/test_rbuiltin.py
@@ -206,7 +206,7 @@
assert hello == "hello world"
fd = os.open(tmpdir, os.O_WRONLY|os.O_CREAT, 777)
os.close(fd)
- raises(OSError, os.write, fd, "hello world")
+ py.test.raises(OSError, os.write, fd, "hello world")
def test_os_write_single_char(self):
tmpdir = str(udir.udir.join("os_write_test_char"))
diff --git a/rpython/rtyper/test/test_rfloat.py
b/rpython/rtyper/test/test_rfloat.py
--- a/rpython/rtyper/test/test_rfloat.py
+++ b/rpython/rtyper/test/test_rfloat.py
@@ -1,4 +1,4 @@
-import sys
+import sys, py
from rpython.translator.translator import TranslationContext
from rpython.annotator import unaryop, binaryop
from rpython.rtyper.test import snippet
@@ -234,7 +234,7 @@
assert break_up_float('-') == ('-', '', '', '')
assert break_up_float('e1') == ('', '', '', '1')
- raises(ValueError, break_up_float, 'e')
+ py.test.raises(ValueError, break_up_float, 'e')
def test_formatd(self):
from rpython.rlib.rfloat import formatd
@@ -397,13 +397,13 @@
class TestOOtype(BaseTestRfloat, OORtypeMixin):
def test_formatd(self):
- skip('formatd is broken on ootype')
+ py.test.skip('formatd is broken on ootype')
def test_formatd_repr(self):
- skip('formatd is broken on ootype')
+ py.test.skip('formatd is broken on ootype')
def test_formatd_huge(self):
- skip('formatd is broken on ootype')
+ py.test.skip('formatd is broken on ootype')
def test_parts_to_float(self):
- skip('parts_to_float is broken on ootype')
+ py.test.skip('parts_to_float is broken on ootype')
diff --git a/rpython/rtyper/test/test_rlist.py
b/rpython/rtyper/test/test_rlist.py
--- a/rpython/rtyper/test/test_rlist.py
+++ b/rpython/rtyper/test/test_rlist.py
@@ -1545,7 +1545,7 @@
raise KeyError # expected case
return prev(l, index)
rlist.ll_getitem_foldable_nonneg = seen_ok
- e = raises(LLException, self.interpret, dummyfn, [])
+ e = py.test.raises(LLException, self.interpret, dummyfn, [])
assert 'KeyError' in str(e.value)
finally:
rlist.ll_getitem_foldable_nonneg = prev
@@ -1571,7 +1571,7 @@
raise KeyError # expected case
return prev(l, index)
rlist.ll_getitem_foldable_nonneg = seen_ok
- e = raises(LLException, self.interpret, dummyfn, [])
+ e = py.test.raises(LLException, self.interpret, dummyfn, [])
assert 'KeyError' in str(e.value)
finally:
rlist.ll_getitem_foldable_nonneg = prev
diff --git a/rpython/rtyper/test/test_rstr.py b/rpython/rtyper/test/test_rstr.py
--- a/rpython/rtyper/test/test_rstr.py
+++ b/rpython/rtyper/test/test_rstr.py
@@ -357,11 +357,11 @@
def f():
s = const('abc')
s.find(s, 0, -10)
- raises(TyperError, self.interpret, f, ())
+ py.test.raises(TyperError, self.interpret, f, ())
def f():
s = const('abc')
s.find(s, -10)
- raises(TyperError, self.interpret, f, ())
+ py.test.raises(TyperError, self.interpret, f, ())
def test_find_empty_string(self):
const = self.const
@@ -752,11 +752,11 @@
def fn():
s = const('abbccc')
s = s.replace(const('a'), const('baz'))
- raises(TyperError, self.interpret, fn, ())
+ py.test.raises(TyperError, self.interpret, fn, ())
def fn():
s = const('abbccc')
s = s.replace(const('abb'), const('c'))
- raises(TyperError, self.interpret, fn, ())
+ py.test.raises(TyperError, self.interpret, fn, ())
def test_int(self):
const = self.const
@@ -888,11 +888,11 @@
def f():
s = const('abc')
s.count(s, 0, -10)
- raises(TyperError, self.interpret, f, ())
+ py.test.raises(TyperError, self.interpret, f, ())
def f():
s = const('abc')
s.count(s, -10)
- raises(TyperError, self.interpret, f, ())
+ py.test.raises(TyperError, self.interpret, f, ())
def test_getitem_exc(self):
const = self.const
diff --git a/rpython/translator/c/test/test_math.py
b/rpython/translator/c/test/test_math.py
--- a/rpython/translator/c/test/test_math.py
+++ b/rpython/translator/c/test/test_math.py
@@ -1,6 +1,6 @@
import py, math
from rpython.rtyper.lltypesystem.module.test.test_ll_math import (MathTests,
- getTester)
+ get_tester)
from rpython.translator.c.test.test_standalone import StandaloneTests
from rpython.rlib import rfloat
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit