Commit 29450b38 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge PR #428 from rntz:cpython-tests

Conflicts:
	from_cpython/Lib/collections.py
	src/codegen/irgen/irgenerator.cpp
parents 27c38df6 f06b7580
......@@ -200,6 +200,8 @@ add_test(NAME check-format COMMAND ${CMAKE_SOURCE_DIR}/tools/check_format.sh ${L
add_test(NAME gc_unittest COMMAND gc_unittest)
add_test(NAME analysis_unittest COMMAND analysis_unittest)
add_test(NAME pyston_defaults COMMAND ${PYTHON_EXE} ${CMAKE_SOURCE_DIR}/tools/tester.py -R ./pyston -j${TEST_THREADS} -a=-S -k ${CMAKE_SOURCE_DIR}/test/tests)
# we pass -I to cpython tests and skip failing ones b/c they are slooow otherwise
add_test(NAME pyston_defaults_cpython_tests COMMAND ${PYTHON_EXE} ${CMAKE_SOURCE_DIR}/tools/tester.py -R ./pyston -j${TEST_THREADS} -a=-S -a=-I -k --exit-code-only --skip-failing ${CMAKE_SOURCE_DIR}/test/cpython)
add_test(NAME pyston_max_compilation_tier COMMAND ${PYTHON_EXE} ${CMAKE_SOURCE_DIR}/tools/tester.py -R ./pyston -j${TEST_THREADS} -a=-O -a=-S -k ${CMAKE_SOURCE_DIR}/test/tests)
add_test(NAME pyston_experimental_pypa_parser COMMAND ${PYTHON_EXE} ${CMAKE_SOURCE_DIR}/tools/tester.py -a=-x -R ./pyston -j${TEST_THREADS} -a=-n -a=-S -k ${CMAKE_SOURCE_DIR}/test/tests)
......
......@@ -490,6 +490,8 @@ check:
$(MAKE) ext_python ext_pyston pyston_dbg
$(PYTHON) $(TOOLS_DIR)/tester.py -R pyston_dbg -j$(TEST_THREADS) -k -a=-S $(TESTS_DIR) $(ARGS)
@# we pass -I to cpython tests & skip failing ones because they are sloooow otherwise
$(PYTHON) $(TOOLS_DIR)/tester.py -R pyston_dbg -j$(TEST_THREADS) -k -a=-S -a=-I --exit-code-only --skip-failing $(TEST_DIR)/cpython $(ARGS)
$(PYTHON) $(TOOLS_DIR)/tester.py -R pyston_dbg -j$(TEST_THREADS) -k -a=-n -a=-x -a=-S $(TESTS_DIR) $(ARGS)
@# skip -O for dbg
......@@ -504,6 +506,8 @@ check:
@# It can be useful to test release mode, since it actually exposes different functionality
@# since we can make different decisions about which internal functions to inline or not.
$(PYTHON) $(TOOLS_DIR)/tester.py -R pyston_release -j$(TEST_THREADS) -k -a=-S $(TESTS_DIR) $(ARGS)
@# we pass -I to cpython tests and skip failing ones because they are sloooow otherwise
$(PYTHON) $(TOOLS_DIR)/tester.py -R pyston_release -j$(TEST_THREADS) -k -a=-S -a=-I --exit-code-only --skip-failing $(TEST_DIR)/cpython $(ARGS)
@# skip -n for dbg
$(PYTHON) $(TOOLS_DIR)/tester.py -R pyston_release -j$(TEST_THREADS) -k -a=-O -a=-x -a=-S $(TESTS_DIR) $(ARGS)
......@@ -920,7 +924,8 @@ clean:
# ex instead of saying "make tests/run_1", I can just write "make run_1"
define make_search
$(eval \
$1: $(TEST_DIR)/tests/$1 ;
$1: $(TESTS_DIR)/$1 ;
$1: $(TEST_DIR)/cpython/$1 ;
$1: ./microbenchmarks/$1 ;
$1: ./minibenchmarks/$1 ;
$1: ./benchmarks/$1 ;
......@@ -936,6 +941,8 @@ $(eval \
.PHONY: test$1 check$1
check$1 test$1: $(PYTHON_EXE_DEPS) pyston$1 ext_pyston
$(PYTHON) $(TOOLS_DIR)/tester.py -R pyston$1 -j$(TEST_THREADS) -a=-S -k $(TESTS_DIR) $(ARGS)
@# we pass -I to cpython tests and skip failing ones because they are sloooow otherwise
$(PYTHON) $(TOOLS_DIR)/tester.py -R pyston$1 -j$(TEST_THREADS) -a=-S -a=-I -k --exit-code-only --skip-failing $(TEST_DIR)/cpython $(ARGS)
$(PYTHON) $(TOOLS_DIR)/tester.py -a=-x -R pyston$1 -j$(TEST_THREADS) -a=-n -a=-S -k $(TESTS_DIR) $(ARGS)
$(PYTHON) $(TOOLS_DIR)/tester.py -R pyston$1 -j$(TEST_THREADS) -a=-O -a=-S -k $(TESTS_DIR) $(ARGS)
......
......@@ -87,6 +87,10 @@ def bisect_left(a, x, lo=0, hi=None):
# Overwrite above definitions with a fast C implementation
try:
# Pyston FIXME: somehow sys.modules['_bisect'] is being bound to 0, which is tripping an assert in importStar.
# import sys
# print '_bisect' in sys.modules
# print sys.modules['_bisect']
from _bisect import *
except ImportError:
pass
P4
16 16
[a_X?
\ No newline at end of file
#define python_width 16
#define python_height 16
static char python_bits[] = {
0xDF, 0xFE, 0x8F, 0xFD, 0x5F, 0xFB, 0xAB, 0xFE, 0xB5, 0x8D, 0xDA, 0x8F,
0xA5, 0x86, 0xFA, 0x83, 0x1A, 0x80, 0x0D, 0x80, 0x0D, 0x80, 0x0F, 0xE0,
0x0F, 0xF8, 0x0F, 0xF8, 0x0F, 0xFC, 0xFF, 0xFF, };
# line 1
'A module docstring.'
import sys, inspect
# line 5
# line 7
def spam(a, b, c, d=3, (e, (f,))=(4, (5,)), *g, **h):
eggs(b + d, c + f)
# line 11
def eggs(x, y):
"A docstring."
global fr, st
fr = inspect.currentframe()
st = inspect.stack()
p = x
q = y // 0
# line 20
class StupidGit:
"""A longer,
indented
docstring."""
# line 27
def abuse(self, a, b, c):
"""Another
\tdocstring
containing
\ttabs
\t
"""
self.argue(a, b, c)
# line 40
def argue(self, a, b, c):
try:
spam(a, b, c)
except:
self.ex = sys.exc_info()
self.tr = inspect.trace()
# line 48
class MalodorousPervert(StupidGit):
pass
Tit = MalodorousPervert
class ParrotDroppings:
pass
class FesteringGob(MalodorousPervert, ParrotDroppings):
pass
# line 1
def wrap(foo=None):
def wrapper(func):
return func
return wrapper
# line 7
def replace(func):
def insteadfunc():
print 'hello'
return insteadfunc
# line 13
@wrap()
@wrap(wrap)
def wrapped():
pass
# line 19
@replace
def gone():
pass
# line 24
oll = lambda m: m
# line 27
tll = lambda g: g and \
g and \
g
# line 32
tlli = lambda d: d and \
d
# line 36
def onelinefunc(): pass
# line 39
def manyargs(arg1, arg2,
arg3, arg4): pass
# line 43
def twolinefunc(m): return m and \
m
# line 47
a = [None,
lambda x: x,
None]
# line 52
def setfunc(func):
globals()["anonymous"] = func
setfunc(lambda x, y: x*y)
# line 57
def with_comment(): # hello
world
# line 61
multiline_sig = [
lambda (x,
y): x+y,
None,
]
# line 68
def func69():
class cls70:
def func71():
pass
return cls70
extra74 = 74
# line 76
def func77(): pass
(extra78, stuff78) = 'xy'
extra79 = 'stop'
# line 81
class cls82:
def func83(): pass
(extra84, stuff84) = 'xy'
extra85 = 'stop'
# line 87
def func88():
# comment
return 90
# line 92
def f():
class X:
def g():
"doc"
return 42
return X
method_in_dynamic_class = f().g.im_func
This diff is collapsed.
This diff is collapsed.
# Common utility functions used by various script execution tests
# e.g. test_cmd_line, test_cmd_line_script and test_runpy
import sys
import os
import re
import os.path
import tempfile
import subprocess
import py_compile
import contextlib
import shutil
try:
import zipfile
except ImportError:
# If Python is build without Unicode support, importing _io will
# fail, which, in turn, means that zipfile cannot be imported
# Most of this module can then still be used.
pass
from test.test_support import strip_python_stderr
# Executing the interpreter in a subprocess
def _assert_python(expected_success, *args, **env_vars):
cmd_line = [sys.executable]
if not env_vars:
cmd_line.append('-E')
cmd_line.extend(args)
# Need to preserve the original environment, for in-place testing of
# shared library builds.
env = os.environ.copy()
env.update(env_vars)
p = subprocess.Popen(cmd_line, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
env=env)
try:
out, err = p.communicate()
finally:
subprocess._cleanup()
p.stdout.close()
p.stderr.close()
rc = p.returncode
err = strip_python_stderr(err)
if (rc and expected_success) or (not rc and not expected_success):
raise AssertionError(
"Process return code is %d, "
"stderr follows:\n%s" % (rc, err.decode('ascii', 'ignore')))
return rc, out, err
def assert_python_ok(*args, **env_vars):
"""
Assert that running the interpreter with `args` and optional environment
variables `env_vars` is ok and return a (return code, stdout, stderr) tuple.
"""
return _assert_python(True, *args, **env_vars)
def assert_python_failure(*args, **env_vars):
"""
Assert that running the interpreter with `args` and optional environment
variables `env_vars` fails and return a (return code, stdout, stderr) tuple.
"""
return _assert_python(False, *args, **env_vars)
def python_exit_code(*args):
cmd_line = [sys.executable, '-E']
cmd_line.extend(args)
with open(os.devnull, 'w') as devnull:
return subprocess.call(cmd_line, stdout=devnull,
stderr=subprocess.STDOUT)
def spawn_python(*args, **kwargs):
cmd_line = [sys.executable, '-E']
cmd_line.extend(args)
return subprocess.Popen(cmd_line, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
**kwargs)
def kill_python(p):
p.stdin.close()
data = p.stdout.read()
p.stdout.close()
# try to cleanup the child so we don't appear to leak when running
# with regrtest -R.
p.wait()
subprocess._cleanup()
return data
def run_python(*args, **kwargs):
if __debug__:
p = spawn_python(*args, **kwargs)
else:
p = spawn_python('-O', *args, **kwargs)
stdout_data = kill_python(p)
return p.wait(), stdout_data
# Script creation utilities
@contextlib.contextmanager
def temp_dir():
dirname = tempfile.mkdtemp()
dirname = os.path.realpath(dirname)
try:
yield dirname
finally:
shutil.rmtree(dirname)
def make_script(script_dir, script_basename, source):
script_filename = script_basename+os.extsep+'py'
script_name = os.path.join(script_dir, script_filename)
script_file = open(script_name, 'w')
script_file.write(source)
script_file.close()
return script_name
def compile_script(script_name):
py_compile.compile(script_name, doraise=True)
if __debug__:
compiled_name = script_name + 'c'
else:
compiled_name = script_name + 'o'
return compiled_name
def make_zip_script(zip_dir, zip_basename, script_name, name_in_zip=None):
zip_filename = zip_basename+os.extsep+'zip'
zip_name = os.path.join(zip_dir, zip_filename)
zip_file = zipfile.ZipFile(zip_name, 'w')
if name_in_zip is None:
name_in_zip = os.path.basename(script_name)
zip_file.write(script_name, name_in_zip)
zip_file.close()
#if test.test_support.verbose:
# zip_file = zipfile.ZipFile(zip_name, 'r')
# print 'Contents of %r:' % zip_name
# zip_file.printdir()
# zip_file.close()
return zip_name, os.path.join(zip_name, name_in_zip)
def make_pkg(pkg_dir):
os.mkdir(pkg_dir)
make_script(pkg_dir, '__init__', '')
def make_zip_pkg(zip_dir, zip_basename, pkg_name, script_basename,
source, depth=1, compiled=False):
unlink = []
init_name = make_script(zip_dir, '__init__', '')
unlink.append(init_name)
init_basename = os.path.basename(init_name)
script_name = make_script(zip_dir, script_basename, source)
unlink.append(script_name)
if compiled:
init_name = compile_script(init_name)
script_name = compile_script(script_name)
unlink.extend((init_name, script_name))
pkg_names = [os.sep.join([pkg_name]*i) for i in range(1, depth+1)]
script_name_in_zip = os.path.join(pkg_names[-1], os.path.basename(script_name))
zip_filename = zip_basename+os.extsep+'zip'
zip_name = os.path.join(zip_dir, zip_filename)
zip_file = zipfile.ZipFile(zip_name, 'w')
for name in pkg_names:
init_name_in_zip = os.path.join(name, init_basename)
zip_file.write(init_name, init_name_in_zip)
zip_file.write(script_name, script_name_in_zip)
zip_file.close()
for name in unlink:
os.unlink(name)
#if test.test_support.verbose:
# zip_file = zipfile.ZipFile(zip_name, 'r')
# print 'Contents of %r:' % zip_name
# zip_file.printdir()
# zip_file.close()
return zip_name, os.path.join(zip_name, script_name_in_zip)
This diff is collapsed.
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="http://ogame182.de/epicblue/formate.css">
<script language="JavaScript" src="js/flotten.js"></script>
</head>
<body>
<script language=JavaScript> if (parent.frames.length == 0) { top.location.href = "http://es.ogame.org/"; } </script> <script language="JavaScript">
function haha(z1) {
eval("location='"+z1.options[z1.selectedIndex].value+"'");
}
</script>
<center>
<table>
<tr>
<td></td>
<td>
<center>
<table>
<tr>
<td><img src="http://ogame182.de/epicblue/planeten/small/s_dschjungelplanet04.jpg" width="50" height="50"></td>
<td>
<table border="1">
<select size="1" onchange="haha(this)">
<option value="/game/flotten1.php?session=8912ae912fec&cp=33875341&mode=Flotte&gid=&messageziel=&re=0" selected>Alien sex friend [2:250:6]</option>
<option value="/game/flotten1.php?session=8912ae912fec&cp=33905100&mode=Flotte&gid=&messageziel=&re=0" >1989 [2:248:14]</option>
<option value="/game/flotten1.php?session=8912ae912fec&cp=34570808&mode=Flotte&gid=&messageziel=&re=0" >1990 [2:248:6]</option>
<option value="/game/flotten1.php?session=8912ae912fec&cp=34570858&mode=Flotte&gid=&messageziel=&re=0" >1991 [2:254:6]</option>
<option value="/game/flotten1.php?session=8912ae912fec&cp=34572929&mode=Flotte&gid=&messageziel=&re=0" >Colonia [2:253:12]</option>
</select>
</table>
</td>
</tr>
</table>
</center>
</td>
<td>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td align="center"></td>
<td align="center" width="85">
<img border="0" src="http://ogame182.de/epicblue/images/metall.gif" width="42" height="22">
</td>
<td align="center" width="85">
<img border="0" src="http://ogame182.de/epicblue/images/kristall.gif" width="42" height="22">
</td>
<td align="center" width="85">
<img border="0" src="http://ogame182.de/epicblue/images/deuterium.gif" width="42" height="22">
</td>
<td align="center" width="85">
<img border="0" src="http://ogame182.de/epicblue/images/energie.gif" width="42" height="22">
</td>
<td align="center"></td>
</tr>
<tr>
<td align="center"><i><b>&nbsp;&nbsp;</b></i></td>
<td align="center" width="85"><i><b><font color="#ffffff">Metal</font></b></i></td>
<td align="center" width="85"><i><b><font color="#ffffff">Cristal</font></b></i></td>
<td align="center" width="85"><i><b><font color="#ffffff">Deuterio</font></b></i></td>
<td align="center" width="85"><i><b><font color="#ffffff">Energa</font></b></i></td>
<td align="center"><i><b>&nbsp;&nbsp;</b></i></td>
</tr>
<tr>
<td align="center"></td>
<td align="center" width="85">160.636</td>
<td align="center" width="85">3.406</td>
<td align="center" width="85">39.230</td>
<td align="center" width="85"><font color=#ff0000>-80</font>/3.965</td>
<td align="center"></td>
</tr>
</table>
</tr>
</table>
</center>
<br />
<script language="JavaScript">
<!--
function link_to_gamepay() {
self.location = "https://www.gamepay.de/?lang=es&serverID=8&userID=129360&gameID=ogame&gui=v2&chksum=a9751afa9e37e6b1b826356bcca45675";
}
//-->
</script>
<center>
<table width="519" border="0" cellpadding="0" cellspacing="1">
<tr height="20">
<td colspan="8" class="c">Flotas (max. 9)</td>
</tr>
<tr height="20">
<th>Num.</th>
<th>Misin</th>
<th>Cantidad</th>
<th>Comienzo</th>
<th>Salida</th>
<th>Objetivo</th>
<th>Llegada</th>
<th>Orden</th>
</tr>
<tr height="20">
<th>1</th>
<th>
<a title="">Espionaje</a>
<a title="Flota en el planeta">(F)</a>
</th>
<th> <a title="Sonda de espionaje: 3
">3</a></th>
<th>[2:250:6]</th>
<th>Wed Aug 9 18:00:02</th>
<th>[2:242:5]</th>
<th>Wed Aug 9 18:01:02</th>
<th>
<form action="flotten1.php?session=8912ae912fec" method="POST">
<input type="hidden" name="order_return" value="25054490" />
<input type="submit" value="Enviar de regreso" />
</form>
</th>
</tr>
<tr height="20">
<th>2</th>
<th>
<a title="">Espionaje</a>
<a title="Volver al planeta">(V)</a>
</th>
<th> <a title="Sonda de espionaje: 3
">3</a></th>
<th>[2:250:6]</th>
<th>Wed Aug 9 17:59:55</th>
<th>[2:242:1]</th>
<th>Wed Aug 9 18:01:55</th>
<th>
</th>
</tr>
</table>
<form action="flotten2.php?session=8912ae912fec" method="POST">
<table width="519" border="0" cellpadding="0" cellspacing="1">
<tr height="20">
<td colspan="4" class="c">Nueva misin: elegir naves</td>
</tr>
<tr height="20">
<th>Naves</th>
<th>Disponibles</th>
<!-- <th>Gesch.</th> -->
<th>-</th>
<th>-</th>
</tr>
<tr height="20">
<th><a title="Velocidad: 8500">Nave pequea de carga</a></th>
<th>10<input type="hidden" name="maxship202" value="10"/></th>
<!-- <th>8500 -->
<input type="hidden" name="consumption202" value="10"/>
<input type="hidden" name="speed202" value="8500" /></th>
<input type="hidden" name="capacity202" value="5000" /></th>
<th><a href="javascript:maxShip('ship202');" >mx</a> </th>
<th><input name="ship202" size="10" value="0" alt="Nave pequea de carga 10"/></th>
</tr>
<tr height="20">
<th><a title="Velocidad: 12750">Nave grande de carga</a></th>
<th>19<input type="hidden" name="maxship203" value="19"/></th>
<!-- <th>12750 -->
<input type="hidden" name="consumption203" value="50"/>
<input type="hidden" name="speed203" value="12750" /></th>
<input type="hidden" name="capacity203" value="25000" /></th>
<th><a href="javascript:maxShip('ship203');" >mx</a> </th>
<th><input name="ship203" size="10" value="0" alt="Nave grande de carga 19"/></th>
</tr>
<tr height="20">
<th><a title="Velocidad: 27000">Crucero</a></th>
<th>6<input type="hidden" name="maxship206" value="6"/></th>
<!-- <th>27000 -->
<input type="hidden" name="consumption206" value="300"/>
<input type="hidden" name="speed206" value="27000" /></th>
<input type="hidden" name="capacity206" value="800" /></th>
<th><a href="javascript:maxShip('ship206');" >mx</a> </th>
<th><input name="ship206" size="10" value="0" alt="Crucero 6"/></th>
</tr>
<tr height="20">
<th><a title="Velocidad: 3400">Reciclador</a></th>
<th>1<input type="hidden" name="maxship209" value="1"/></th>
<!-- <th>3400 -->
<input type="hidden" name="consumption209" value="300"/>
<input type="hidden" name="speed209" value="3400" /></th>
<input type="hidden" name="capacity209" value="20000" /></th>
<th><a href="javascript:maxShip('ship209');" >mx</a> </th>
<th><input name="ship209" size="10" value="0" alt="Reciclador 1"/></th>
</tr>
<tr height="20">
<th><a title="Velocidad: 170000000">Sonda de espionaje</a></th>
<th>139<input type="hidden" name="maxship210" value="139"/></th>
<!-- <th>170000000 -->
<input type="hidden" name="consumption210" value="1"/>
<input type="hidden" name="speed210" value="170000000" /></th>
<input type="hidden" name="capacity210" value="5" /></th>
<th><a href="javascript:maxShip('ship210');" >mx</a> </th>
<th><input name="ship210" size="10" value="0" alt="Sonda de espionaje 139"/></th>
</tr>
<tr height="20">
<th colspan="2"><a href="javascript:noShips();" >Ninguna nave</a></th>
<th colspan="2"><a href="javascript:maxShips();" >Todas las naves</a></th>
</tr>
<tr height="20">
<th colspan="4"><input type="submit" value="Continuar" /></th>
</tr>
<tr><th colspan=4>
<iframe id='a44fb522' name='a44fb522' src='http://ads.gameforgeads.de/adframe.php?n=a44fb522&amp;what=zone:578' framespacing='0' frameborder='no' scrolling='no' width='468' height='60'></iframe>
<br><center></center></br>
</th></tr>
</form>
</table>
</body>
</html>
This diff is collapsed.
"""Test program for MimeWriter module.
The test program was too big to comfortably fit in the MimeWriter
class, so it's here in its own file.
This should generate Barry's example, modulo some quotes and newlines.
"""
import unittest, StringIO
from test.test_support import run_unittest, import_module
import_module("MimeWriter", deprecated=True)
from MimeWriter import MimeWriter
SELLER = '''\
INTERFACE Seller-1;
TYPE Seller = OBJECT
DOCUMENTATION "A simple Seller interface to test ILU"
METHODS
price():INTEGER,
END;
'''
BUYER = '''\
class Buyer:
def __setup__(self, maxprice):
self._maxprice = maxprice
def __main__(self, kos):
"""Entry point upon arrival at a new KOS."""
broker = kos.broker()
# B4 == Barry's Big Bass Business :-)
seller = broker.lookup('Seller_1.Seller', 'B4')
if seller:
price = seller.price()
print 'Seller wants $', price, '... '
if price > self._maxprice:
print 'too much!'
else:
print "I'll take it!"
else:
print 'no seller found here'
''' # Don't ask why this comment is here
STATE = '''\
# instantiate a buyer instance and put it in a magic place for the KOS
# to find.
__kp__ = Buyer()
__kp__.__setup__(500)
'''
SIMPLE_METADATA = [
("Interpreter", "python"),
("Interpreter-Version", "1.3"),
("Owner-Name", "Barry Warsaw"),
("Owner-Rendezvous", "bwarsaw@cnri.reston.va.us"),
("Home-KSS", "kss.cnri.reston.va.us"),
("Identifier", "hdl://cnri.kss/my_first_knowbot"),
("Launch-Date", "Mon Feb 12 16:39:03 EST 1996"),
]
COMPLEX_METADATA = [
("Metadata-Type", "complex"),
("Metadata-Key", "connection"),
("Access", "read-only"),
("Connection-Description", "Barry's Big Bass Business"),
("Connection-Id", "B4"),
("Connection-Direction", "client"),
]
EXTERNAL_METADATA = [
("Metadata-Type", "complex"),
("Metadata-Key", "generic-interface"),
("Access", "read-only"),
("Connection-Description", "Generic Interface for All Knowbots"),
("Connection-Id", "generic-kp"),
("Connection-Direction", "client"),
]
OUTPUT = '''\
From: bwarsaw@cnri.reston.va.us
Date: Mon Feb 12 17:21:48 EST 1996
To: kss-submit@cnri.reston.va.us
MIME-Version: 1.0
Content-Type: multipart/knowbot;
boundary="801spam999";
version="0.1"
This is a multi-part message in MIME format.
--801spam999
Content-Type: multipart/knowbot-metadata;
boundary="802spam999"
--802spam999
Content-Type: message/rfc822
KP-Metadata-Type: simple
KP-Access: read-only
KPMD-Interpreter: python
KPMD-Interpreter-Version: 1.3
KPMD-Owner-Name: Barry Warsaw
KPMD-Owner-Rendezvous: bwarsaw@cnri.reston.va.us
KPMD-Home-KSS: kss.cnri.reston.va.us
KPMD-Identifier: hdl://cnri.kss/my_first_knowbot
KPMD-Launch-Date: Mon Feb 12 16:39:03 EST 1996
--802spam999
Content-Type: text/isl
KP-Metadata-Type: complex
KP-Metadata-Key: connection
KP-Access: read-only
KP-Connection-Description: Barry's Big Bass Business
KP-Connection-Id: B4
KP-Connection-Direction: client
INTERFACE Seller-1;
TYPE Seller = OBJECT
DOCUMENTATION "A simple Seller interface to test ILU"
METHODS
price():INTEGER,
END;
--802spam999
Content-Type: message/external-body;
access-type="URL";
URL="hdl://cnri.kss/generic-knowbot"
Content-Type: text/isl
KP-Metadata-Type: complex
KP-Metadata-Key: generic-interface
KP-Access: read-only
KP-Connection-Description: Generic Interface for All Knowbots
KP-Connection-Id: generic-kp
KP-Connection-Direction: client
--802spam999--
--801spam999
Content-Type: multipart/knowbot-code;
boundary="803spam999"
--803spam999
Content-Type: text/plain
KP-Module-Name: BuyerKP
class Buyer:
def __setup__(self, maxprice):
self._maxprice = maxprice
def __main__(self, kos):
"""Entry point upon arrival at a new KOS."""
broker = kos.broker()
# B4 == Barry's Big Bass Business :-)
seller = broker.lookup('Seller_1.Seller', 'B4')
if seller:
price = seller.price()
print 'Seller wants $', price, '... '
if price > self._maxprice:
print 'too much!'
else:
print "I'll take it!"
else:
print 'no seller found here'
--803spam999--
--801spam999
Content-Type: multipart/knowbot-state;
boundary="804spam999"
KP-Main-Module: main
--804spam999
Content-Type: text/plain
KP-Module-Name: main
# instantiate a buyer instance and put it in a magic place for the KOS
# to find.
__kp__ = Buyer()
__kp__.__setup__(500)
--804spam999--
--801spam999--
'''
class MimewriterTest(unittest.TestCase):
def test(self):
buf = StringIO.StringIO()
# Toplevel headers
toplevel = MimeWriter(buf)
toplevel.addheader("From", "bwarsaw@cnri.reston.va.us")
toplevel.addheader("Date", "Mon Feb 12 17:21:48 EST 1996")
toplevel.addheader("To", "kss-submit@cnri.reston.va.us")
toplevel.addheader("MIME-Version", "1.0")
# Toplevel body parts
f = toplevel.startmultipartbody("knowbot", "801spam999",
[("version", "0.1")], prefix=0)
f.write("This is a multi-part message in MIME format.\n")
# First toplevel body part: metadata
md = toplevel.nextpart()
md.startmultipartbody("knowbot-metadata", "802spam999")
# Metadata part 1
md1 = md.nextpart()
md1.addheader("KP-Metadata-Type", "simple")
md1.addheader("KP-Access", "read-only")
m = MimeWriter(md1.startbody("message/rfc822"))
for key, value in SIMPLE_METADATA:
m.addheader("KPMD-" + key, value)
m.flushheaders()
del md1
# Metadata part 2
md2 = md.nextpart()
for key, value in COMPLEX_METADATA:
md2.addheader("KP-" + key, value)
f = md2.startbody("text/isl")
f.write(SELLER)
del md2
# Metadata part 3
md3 = md.nextpart()
f = md3.startbody("message/external-body",
[("access-type", "URL"),
("URL", "hdl://cnri.kss/generic-knowbot")])
m = MimeWriter(f)
for key, value in EXTERNAL_METADATA:
md3.addheader("KP-" + key, value)
md3.startbody("text/isl")
# Phantom body doesn't need to be written
md.lastpart()
# Second toplevel body part: code
code = toplevel.nextpart()
code.startmultipartbody("knowbot-code", "803spam999")
# Code: buyer program source
buyer = code.nextpart()
buyer.addheader("KP-Module-Name", "BuyerKP")
f = buyer.startbody("text/plain")
f.write(BUYER)
code.lastpart()
# Third toplevel body part: state
state = toplevel.nextpart()
state.addheader("KP-Main-Module", "main")
state.startmultipartbody("knowbot-state", "804spam999")
# State: a bunch of assignments
st = state.nextpart()
st.addheader("KP-Module-Name", "main")
f = st.startbody("text/plain")
f.write(STATE)
state.lastpart()
# End toplevel body parts
toplevel.lastpart()
self.assertEqual(buf.getvalue(), OUTPUT)
def test_main():
run_unittest(MimewriterTest)
if __name__ == '__main__':
test_main()
"""
These tests only check url parsing for now.
We don't want to require the 'network' resource.
"""
import os, unittest
from SimpleHTTPServer import SimpleHTTPRequestHandler
from test import test_support
class SocketlessRequestHandler (SimpleHTTPRequestHandler):
def __init__(self):
pass
class SimpleHTTPRequestHandlerTestCase(unittest.TestCase):
""" Test url parsing """
def setUp (self):
self.translated = os.getcwd()
self.translated = os.path.join(self.translated, 'filename')
self.handler = SocketlessRequestHandler ()
def test_queryArguments (self):
path = self.handler.translate_path ('/filename')
self.assertEqual (path, self.translated)
path = self.handler.translate_path ('/filename?foo=bar')
self.assertEqual (path, self.translated)
path = self.handler.translate_path ('/filename?a=b&spam=eggs#zot')
self.assertEqual (path, self.translated)
def test_startWithDoubleSlash (self):
path = self.handler.translate_path ('//filename')
self.assertEqual (path, self.translated)
path = self.handler.translate_path ('//filename?foo=bar')
self.assertEqual (path, self.translated)
def test_main():
test_support.run_unittest(SimpleHTTPRequestHandlerTestCase)
if __name__ == "__main__":
test_main()
This diff is collapsed.
# expected: fail
# Copyright 2007 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Unit tests for abc.py."""
import unittest, weakref
from test import test_support
import abc
from inspect import isabstract
class TestABC(unittest.TestCase):
def test_abstractmethod_basics(self):
@abc.abstractmethod
def foo(self): pass
self.assertTrue(foo.__isabstractmethod__)
def bar(self): pass
self.assertFalse(hasattr(bar, "__isabstractmethod__"))
def test_abstractproperty_basics(self):
@abc.abstractproperty
def foo(self): pass
self.assertTrue(foo.__isabstractmethod__)
def bar(self): pass
self.assertFalse(hasattr(bar, "__isabstractmethod__"))
class C:
__metaclass__ = abc.ABCMeta
@abc.abstractproperty
def foo(self): return 3
class D(C):
@property
def foo(self): return super(D, self).foo
self.assertEqual(D().foo, 3)
def test_abstractmethod_integration(self):
for abstractthing in [abc.abstractmethod, abc.abstractproperty]:
class C:
__metaclass__ = abc.ABCMeta
@abstractthing
def foo(self): pass # abstract
def bar(self): pass # concrete
self.assertEqual(C.__abstractmethods__, set(["foo"]))
self.assertRaises(TypeError, C) # because foo is abstract
self.assertTrue(isabstract(C))
class D(C):
def bar(self): pass # concrete override of concrete
self.assertEqual(D.__abstractmethods__, set(["foo"]))
self.assertRaises(TypeError, D) # because foo is still abstract
self.assertTrue(isabstract(D))
class E(D):
def foo(self): pass
self.assertEqual(E.__abstractmethods__, set())
E() # now foo is concrete, too
self.assertFalse(isabstract(E))
class F(E):
@abstractthing
def bar(self): pass # abstract override of concrete
self.assertEqual(F.__abstractmethods__, set(["bar"]))
self.assertRaises(TypeError, F) # because bar is abstract now
self.assertTrue(isabstract(F))
def test_subclass_oldstyle_class(self):
class A:
__metaclass__ = abc.ABCMeta
class OldstyleClass:
pass
self.assertFalse(issubclass(OldstyleClass, A))
self.assertFalse(issubclass(A, OldstyleClass))
def test_isinstance_class(self):
class A:
__metaclass__ = abc.ABCMeta
class OldstyleClass:
pass
self.assertFalse(isinstance(OldstyleClass, A))
self.assertTrue(isinstance(OldstyleClass, type(OldstyleClass)))
self.assertFalse(isinstance(A, OldstyleClass))
# This raises a recursion depth error, but is low-priority:
# self.assertTrue(isinstance(A, abc.ABCMeta))
def test_registration_basics(self):
class A:
__metaclass__ = abc.ABCMeta
class B(object):
pass
b = B()
self.assertFalse(issubclass(B, A))
self.assertFalse(issubclass(B, (A,)))
self.assertNotIsInstance(b, A)
self.assertNotIsInstance(b, (A,))
A.register(B)
self.assertTrue(issubclass(B, A))
self.assertTrue(issubclass(B, (A,)))
self.assertIsInstance(b, A)
self.assertIsInstance(b, (A,))
class C(B):
pass
c = C()
self.assertTrue(issubclass(C, A))
self.assertTrue(issubclass(C, (A,)))
self.assertIsInstance(c, A)
self.assertIsInstance(c, (A,))
def test_isinstance_invalidation(self):
class A:
__metaclass__ = abc.ABCMeta
class B(object):
pass
b = B()
self.assertFalse(isinstance(b, A))
self.assertFalse(isinstance(b, (A,)))
A.register(B)
self.assertTrue(isinstance(b, A))
self.assertTrue(isinstance(b, (A,)))
def test_registration_builtins(self):
class A:
__metaclass__ = abc.ABCMeta
A.register(int)
self.assertIsInstance(42, A)
self.assertIsInstance(42, (A,))
self.assertTrue(issubclass(int, A))
self.assertTrue(issubclass(int, (A,)))
class B(A):
pass
B.register(basestring)
self.assertIsInstance("", A)
self.assertIsInstance("", (A,))
self.assertTrue(issubclass(str, A))
self.assertTrue(issubclass(str, (A,)))
def test_registration_edge_cases(self):
class A:
__metaclass__ = abc.ABCMeta
A.register(A) # should pass silently
class A1(A):
pass
self.assertRaises(RuntimeError, A1.register, A) # cycles not allowed
class B(object):
pass
A1.register(B) # ok
A1.register(B) # should pass silently
class C(A):
pass
A.register(C) # should pass silently
self.assertRaises(RuntimeError, C.register, A) # cycles not allowed
C.register(B) # ok
def test_register_non_class(self):
class A(object):
__metaclass__ = abc.ABCMeta
self.assertRaisesRegexp(TypeError, "Can only register classes",
A.register, 4)
def test_registration_transitiveness(self):
class A:
__metaclass__ = abc.ABCMeta
self.assertTrue(issubclass(A, A))
self.assertTrue(issubclass(A, (A,)))
class B:
__metaclass__ = abc.ABCMeta
self.assertFalse(issubclass(A, B))
self.assertFalse(issubclass(A, (B,)))
self.assertFalse(issubclass(B, A))
self.assertFalse(issubclass(B, (A,)))
class C:
__metaclass__ = abc.ABCMeta
A.register(B)
class B1(B):
pass
self.assertTrue(issubclass(B1, A))
self.assertTrue(issubclass(B1, (A,)))
class C1(C):
pass
B1.register(C1)
self.assertFalse(issubclass(C, B))
self.assertFalse(issubclass(C, (B,)))
self.assertFalse(issubclass(C, B1))
self.assertFalse(issubclass(C, (B1,)))
self.assertTrue(issubclass(C1, A))
self.assertTrue(issubclass(C1, (A,)))
self.assertTrue(issubclass(C1, B))
self.assertTrue(issubclass(C1, (B,)))
self.assertTrue(issubclass(C1, B1))
self.assertTrue(issubclass(C1, (B1,)))
C1.register(int)
class MyInt(int):
pass
self.assertTrue(issubclass(MyInt, A))
self.assertTrue(issubclass(MyInt, (A,)))
self.assertIsInstance(42, A)
self.assertIsInstance(42, (A,))
def test_all_new_methods_are_called(self):
class A:
__metaclass__ = abc.ABCMeta
class B(object):
counter = 0
def __new__(cls):
B.counter += 1
return super(B, cls).__new__(cls)
class C(A, B):
pass
self.assertEqual(B.counter, 0)
C()
self.assertEqual(B.counter, 1)
def test_cache_leak(self):
# See issue #2521.
class A(object):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def f(self):
pass
class C(A):
def f(self):
A.f(self)
r = weakref.ref(C)
# Trigger cache.
C().f()
del C
test_support.gc_collect()
self.assertEqual(r(), None)
def test_main():
test_support.run_unittest(TestABC)
if __name__ == "__main__":
unittest.main()
# expected: fail
"""Unit tests for numbers.py."""
import math
import unittest
from numbers import Complex, Real, Rational, Integral
from test import test_support
class TestNumbers(unittest.TestCase):
def test_int(self):
self.assertTrue(issubclass(int, Integral))
self.assertTrue(issubclass(int, Complex))
self.assertEqual(7, int(7).real)
self.assertEqual(0, int(7).imag)
self.assertEqual(7, int(7).conjugate())
self.assertEqual(7, int(7).numerator)
self.assertEqual(1, int(7).denominator)
def test_long(self):
self.assertTrue(issubclass(long, Integral))
self.assertTrue(issubclass(long, Complex))
self.assertEqual(7, long(7).real)
self.assertEqual(0, long(7).imag)
self.assertEqual(7, long(7).conjugate())
self.assertEqual(7, long(7).numerator)
self.assertEqual(1, long(7).denominator)
def test_float(self):
self.assertFalse(issubclass(float, Rational))
self.assertTrue(issubclass(float, Real))
self.assertEqual(7.3, float(7.3).real)
self.assertEqual(0, float(7.3).imag)
self.assertEqual(7.3, float(7.3).conjugate())
def test_complex(self):
self.assertFalse(issubclass(complex, Real))
self.assertTrue(issubclass(complex, Complex))
c1, c2 = complex(3, 2), complex(4,1)
# XXX: This is not ideal, but see the comment in math_trunc().
self.assertRaises(AttributeError, math.trunc, c1)
self.assertRaises(TypeError, float, c1)
self.assertRaises(TypeError, int, c1)
def test_main():
test_support.run_unittest(TestNumbers)
if __name__ == "__main__":
unittest.main()
# expected: fail
# Augmented assignment test.
from test.test_support import run_unittest, check_py3k_warnings
import unittest
class AugAssignTest(unittest.TestCase):
def testBasic(self):
x = 2
x += 1
x *= 2
x **= 2
x -= 8
x //= 5
x %= 3
x &= 2
x |= 5
x ^= 1
x /= 2
if 1/2 == 0:
# classic division
self.assertEqual(x, 3)
else:
# new-style division (with -Qnew)
self.assertEqual(x, 3.0)
def test_with_unpacking(self):
self.assertRaises(SyntaxError, compile, "x, b += 3", "<test>", "exec")
def testInList(self):
x = [2]
x[0] += 1
x[0] *= 2
x[0] **= 2
x[0] -= 8
x[0] //= 5
x[0] %= 3
x[0] &= 2
x[0] |= 5
x[0] ^= 1
x[0] /= 2
if 1/2 == 0:
self.assertEqual(x[0], 3)
else:
self.assertEqual(x[0], 3.0)
def testInDict(self):
x = {0: 2}
x[0] += 1
x[0] *= 2
x[0] **= 2
x[0] -= 8
x[0] //= 5
x[0] %= 3
x[0] &= 2
x[0] |= 5
x[0] ^= 1
x[0] /= 2
if 1/2 == 0:
self.assertEqual(x[0], 3)
else:
self.assertEqual(x[0], 3.0)
def testSequences(self):
x = [1,2]
x += [3,4]
x *= 2
self.assertEqual(x, [1, 2, 3, 4, 1, 2, 3, 4])
x = [1, 2, 3]
y = x
x[1:2] *= 2
y[1:2] += [1]
self.assertEqual(x, [1, 2, 1, 2, 3])
self.assertTrue(x is y)
def testCustomMethods1(self):
class aug_test:
def __init__(self, value):
self.val = value
def __radd__(self, val):
return self.val + val
def __add__(self, val):
return aug_test(self.val + val)
class aug_test2(aug_test):
def __iadd__(self, val):
self.val = self.val + val
return self
class aug_test3(aug_test):
def __iadd__(self, val):
return aug_test3(self.val + val)
x = aug_test(1)
y = x
x += 10
self.assertIsInstance(x, aug_test)
self.assertTrue(y is not x)
self.assertEqual(x.val, 11)
x = aug_test2(2)
y = x
x += 10
self.assertTrue(y is x)
self.assertEqual(x.val, 12)
x = aug_test3(3)
y = x
x += 10
self.assertIsInstance(x, aug_test3)
self.assertTrue(y is not x)
self.assertEqual(x.val, 13)
def testCustomMethods2(test_self):
output = []
class testall:
def __add__(self, val):
output.append("__add__ called")
def __radd__(self, val):
output.append("__radd__ called")
def __iadd__(self, val):
output.append("__iadd__ called")
return self
def __sub__(self, val):
output.append("__sub__ called")
def __rsub__(self, val):
output.append("__rsub__ called")
def __isub__(self, val):
output.append("__isub__ called")
return self
def __mul__(self, val):
output.append("__mul__ called")
def __rmul__(self, val):
output.append("__rmul__ called")
def __imul__(self, val):
output.append("__imul__ called")
return self
def __div__(self, val):
output.append("__div__ called")
def __rdiv__(self, val):
output.append("__rdiv__ called")
def __idiv__(self, val):
output.append("__idiv__ called")
return self
def __floordiv__(self, val):
output.append("__floordiv__ called")
return self
def __ifloordiv__(self, val):
output.append("__ifloordiv__ called")
return self
def __rfloordiv__(self, val):
output.append("__rfloordiv__ called")
return self
def __truediv__(self, val):
output.append("__truediv__ called")
return self
def __itruediv__(self, val):
output.append("__itruediv__ called")
return self
def __mod__(self, val):
output.append("__mod__ called")
def __rmod__(self, val):
output.append("__rmod__ called")
def __imod__(self, val):
output.append("__imod__ called")
return self
def __pow__(self, val):
output.append("__pow__ called")
def __rpow__(self, val):
output.append("__rpow__ called")
def __ipow__(self, val):
output.append("__ipow__ called")
return self
def __or__(self, val):
output.append("__or__ called")
def __ror__(self, val):
output.append("__ror__ called")
def __ior__(self, val):
output.append("__ior__ called")
return self
def __and__(self, val):
output.append("__and__ called")
def __rand__(self, val):
output.append("__rand__ called")
def __iand__(self, val):
output.append("__iand__ called")
return self
def __xor__(self, val):
output.append("__xor__ called")
def __rxor__(self, val):
output.append("__rxor__ called")
def __ixor__(self, val):
output.append("__ixor__ called")
return self
def __rshift__(self, val):
output.append("__rshift__ called")
def __rrshift__(self, val):
output.append("__rrshift__ called")
def __irshift__(self, val):
output.append("__irshift__ called")
return self
def __lshift__(self, val):
output.append("__lshift__ called")
def __rlshift__(self, val):
output.append("__rlshift__ called")
def __ilshift__(self, val):
output.append("__ilshift__ called")
return self
x = testall()
x + 1
1 + x
x += 1
x - 1
1 - x
x -= 1
x * 1
1 * x
x *= 1
if 1/2 == 0:
x / 1
1 / x
x /= 1
else:
# True division is in effect, so "/" doesn't map to __div__ etc;
# but the canned expected-output file requires that those get called.
x.__div__(1)
x.__rdiv__(1)
x.__idiv__(1)
x // 1
1 // x
x //= 1
x % 1
1 % x
x %= 1
x ** 1
1 ** x
x **= 1
x | 1
1 | x
x |= 1
x & 1
1 & x
x &= 1
x ^ 1
1 ^ x
x ^= 1
x >> 1
1 >> x
x >>= 1
x << 1
1 << x
x <<= 1
test_self.assertEqual(output, '''\
__add__ called
__radd__ called
__iadd__ called
__sub__ called
__rsub__ called
__isub__ called
__mul__ called
__rmul__ called
__imul__ called
__div__ called
__rdiv__ called
__idiv__ called
__floordiv__ called
__rfloordiv__ called
__ifloordiv__ called
__mod__ called
__rmod__ called
__imod__ called
__pow__ called
__rpow__ called
__ipow__ called
__or__ called
__ror__ called
__ior__ called
__and__ called
__rand__ called
__iand__ called
__xor__ called
__rxor__ called
__ixor__ called
__rshift__ called
__rrshift__ called
__irshift__ called
__lshift__ called
__rlshift__ called
__ilshift__ called
'''.splitlines())
def test_main():
with check_py3k_warnings(("classic int division", DeprecationWarning)):
run_unittest(AugAssignTest)
if __name__ == '__main__':
test_main()
This diff is collapsed.
##import Bastion
##
##Bastion._test()
from test import test_support
from test.test_support import bigaddrspacetest, MAX_Py_ssize_t
import unittest
import operator
import sys
class StrTest(unittest.TestCase):
@bigaddrspacetest
def test_concat(self):
s1 = 'x' * MAX_Py_ssize_t
self.assertRaises(OverflowError, operator.add, s1, '?')
@bigaddrspacetest
def test_optimized_concat(self):
x = 'x' * MAX_Py_ssize_t
try:
x = x + '?' # this statement uses a fast path in ceval.c
except OverflowError:
pass
else:
self.fail("should have raised OverflowError")
try:
x += '?' # this statement uses a fast path in ceval.c
except OverflowError:
pass
else:
self.fail("should have raised OverflowError")
self.assertEqual(len(x), MAX_Py_ssize_t)
### the following test is pending a patch
# (http://mail.python.org/pipermail/python-dev/2006-July/067774.html)
#@bigaddrspacetest
#def test_repeat(self):
# self.assertRaises(OverflowError, operator.mul, 'x', MAX_Py_ssize_t + 1)
def test_main():
test_support.run_unittest(StrTest)
if __name__ == '__main__':
if len(sys.argv) > 1:
test_support.set_memlimit(sys.argv[1])
test_main()
This diff is collapsed.
"""Test script for the binhex C module
Uses the mechanism of the python binhex module
Based on an original test by Roger E. Masse.
"""
import binhex
import os
import unittest
from test import test_support
class BinHexTestCase(unittest.TestCase):
def setUp(self):
self.fname1 = test_support.TESTFN + "1"
self.fname2 = test_support.TESTFN + "2"
def tearDown(self):
try: os.unlink(self.fname1)
except OSError: pass
try: os.unlink(self.fname2)
except OSError: pass
DATA = 'Jack is my hero'
def test_binhex(self):
f = open(self.fname1, 'w')
f.write(self.DATA)
f.close()
binhex.binhex(self.fname1, self.fname2)
binhex.hexbin(self.fname2, self.fname1)
f = open(self.fname1, 'r')
finish = f.readline()
f.close()
self.assertEqual(self.DATA, finish)
def test_main():
test_support.run_unittest(BinHexTestCase)
if __name__ == "__main__":
test_main()
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
"""Unit tests for buffer objects.
For now, tests just new or changed functionality.
"""
import sys
import unittest
from test import test_support
class BufferTests(unittest.TestCase):
def test_extended_getslice(self):
# Test extended slicing by comparing with list slicing.
s = "".join(chr(c) for c in list(range(255, -1, -1)))
b = buffer(s)
indices = (0, None, 1, 3, 19, 300, -1, -2, -31, -300)
for start in indices:
for stop in indices:
# Skip step 0 (invalid)
for step in indices[1:]:
self.assertEqual(b[start:stop:step],
s[start:stop:step])
def test_newbuffer_interface(self):
# Test that the buffer object has the new buffer interface
# as used by the memoryview object
s = "".join(chr(c) for c in list(range(255, -1, -1)))
b = buffer(s)
m = memoryview(b) # Should not raise an exception
self.assertEqual(m.tobytes(), s)
def test_large_buffer_size_and_offset(self):
data = bytearray('hola mundo')
buf = buffer(data, sys.maxsize, sys.maxsize)
self.assertEqual(buf[:4096], "")
def test_main():
with test_support.check_py3k_warnings(("buffer.. not supported",
DeprecationWarning)):
test_support.run_unittest(BufferTests)
if __name__ == "__main__":
test_main()
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
"""Test the errno module
Roger E. Masse
"""
import errno
from test import test_support
import unittest
std_c_errors = frozenset(['EDOM', 'ERANGE'])
class ErrnoAttributeTests(unittest.TestCase):
def test_for_improper_attributes(self):
# No unexpected attributes should be on the module.
for error_code in std_c_errors:
self.assertTrue(hasattr(errno, error_code),
"errno is missing %s" % error_code)
def test_using_errorcode(self):
# Every key value in errno.errorcode should be on the module.
for value in errno.errorcode.itervalues():
self.assertTrue(hasattr(errno, value), 'no %s attr in errno' % value)
class ErrorcodeTests(unittest.TestCase):
def test_attributes_in_errorcode(self):
for attribute in errno.__dict__.iterkeys():
if attribute.isupper():
self.assertIn(getattr(errno, attribute), errno.errorcode,
'no %s attr in errno.errorcode' % attribute)
def test_main():
test_support.run_unittest(ErrnoAttributeTests, ErrorcodeTests)
if __name__ == '__main__':
test_main()
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment