Commit b0991a74 authored by Marius Wachtler's avatar Marius Wachtler

Merge pull request #1056 from undingen/file_fixes

add support for avro
parents 66cbe50c c178fbe0
# expected: fail
# NOTE: this file tests the new `io` library backported from Python 3.x.
# Similar tests for the builtin file object can be found in test_file2k.py.
......@@ -27,6 +26,8 @@ class AutoFileTests(unittest.TestCase):
self.f.close()
os.remove(TESTFN)
# pyston change:
@unittest.skip("does not work with GC")
def testWeakRefs(self):
# verify weak references
p = proxy(self.f)
......
......@@ -1882,6 +1882,8 @@ void setupFile() {
new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, offsetof(BoxedFile, f_name), true));
file_cls->giveAttr("mode",
new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, offsetof(BoxedFile, f_mode), true));
file_cls->giveAttr("encoding",
new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, offsetof(BoxedFile, f_encoding), true));
file_cls->giveAttr("__new__", new BoxedFunction(FunctionMetadata::create((void*)fileNew, UNKNOWN, 4, false, false),
{ boxString("r"), boxInt(-1) }));
......
......@@ -5726,6 +5726,8 @@ Box* getiter(Box* o) {
Box* r = NULL;
if (PyType_HasFeature(type, Py_TPFLAGS_HAVE_ITER) && type->tp_iter != slot_tp_iter && type->tp_iter) {
r = type->tp_iter(o);
if (!r && PyErr_Occurred())
throwCAPIException();
} else {
r = type->callIterIC(o);
}
......
......@@ -97,7 +97,6 @@ test_extcall f(**kw) crashes if kw isn't a dict
test_file2k we abort when you try to open() a directory
test_file_eintr not sure
test_fileio [unknown]
test_file wontfix: we don't destruct file objects when the test wants
test_fork1 [unknown]
test_frozen [unknown]
test_ftplib [unknown]
......
import os, sys, subprocess
sys.path.append(os.path.dirname(__file__) + "/../lib")
from test_helper import create_virtenv, run_test
ENV_NAME = "avro_test_env_" + os.path.basename(sys.executable)
PYTHON_EXE = os.path.abspath(os.path.join(ENV_NAME, "bin", "python"))
NOSETESTS_EXE = os.path.abspath(os.path.join(ENV_NAME, "bin", "nosetests"))
AVRO_DIR = os.path.abspath(os.path.join(ENV_NAME, "avro-1.7.7"))
packages = ["nose==1.3.7", "avro==1.7.7"]
create_virtenv(ENV_NAME, packages, force_create = True)
url = "https://pypi.python.org/packages/source/a/avro/avro-1.7.7.tar.gz"
subprocess.check_call(["wget", url], cwd=ENV_NAME)
subprocess.check_call(["tar", "-zxf", "avro-1.7.7.tar.gz"], cwd=ENV_NAME)
env = os.environ
env["PYTHONPATH"] = os.path.abspath(os.path.join(ENV_NAME, "site-packages"))
# this tests also fail when run in cpython with nose.
# pytest makes two of this work but we can't currently run pytest...
expected = [{'ran': 51, 'errors': 3}]
run_test([NOSETESTS_EXE], env=env, cwd=AVRO_DIR, expected=expected)
......@@ -20,6 +20,7 @@ def chop(s):
for desc in [sys.stderr, sys.stdout, sys.stdin]:
print chop(str(desc))
print desc.encoding
f = open("/dev/null", 'w')
print chop(str(f))
......
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