Skip to content

fix all unit tests and add python 2.6 build to travis #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 27, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: python
python:
- 2.6
- 2.7
before_install:
- sudo apt-get install software-properties-common
Expand Down
26 changes: 21 additions & 5 deletions pythonnet/setupmono.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from distutils.command.build_ext import build_ext
from distutils.sysconfig import get_config_vars
from platform import architecture
from subprocess import check_output, check_call
from subprocess import Popen, CalledProcessError, PIPE, check_call
import shutil
import sys
import os
Expand Down Expand Up @@ -77,10 +77,10 @@ def build_extension(self, ext):


def _build_monoclr(self, ext):
mono_libs = check_output("pkg-config --libs mono-2", shell=True)
mono_cflags = check_output("pkg-config --cflags mono-2", shell=True)
glib_libs = check_output("pkg-config --libs glib-2.0", shell=True)
glib_cflags = check_output("pkg-config --cflags glib-2.0", shell=True)
mono_libs = _check_output("pkg-config --libs mono-2", shell=True)
mono_cflags = _check_output("pkg-config --cflags mono-2", shell=True)
glib_libs = _check_output("pkg-config --libs glib-2.0", shell=True)
glib_cflags = _check_output("pkg-config --cflags glib-2.0", shell=True)
cflags = mono_cflags.strip() + " " + glib_cflags.strip()
libs = mono_libs.strip() + " " + glib_libs.strip()

Expand Down Expand Up @@ -129,6 +129,22 @@ def _build_monoclr(self, ext):
debug=self.debug)


def _check_output(*popenargs, **kwargs):
"""subprocess.check_output from python 2.7.
Added here to support building for earlier versions
of Python.
"""
process = Popen(stdout=PIPE, *popenargs, **kwargs)
output, unused_err = process.communicate()
retcode = process.poll()
if retcode:
cmd = kwargs.get("args")
if cmd is None:
cmd = popenargs[0]
raise CalledProcessError(retcode, cmd, output=output)
return output


if __name__ == "__main__":
setup(name="pythonnet",
ext_modules=[
Expand Down
8 changes: 8 additions & 0 deletions pythonnet/src/runtime/converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,14 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result,
if (Exceptions.ErrorOccurred()) {
goto overflow;
}

IntPtr check = Runtime.PyLong_FromUnsignedLong(ui);
int err = Runtime.PyObject_Compare(check, op);
Runtime.Decref(check);
if (0 != err || Exceptions.ErrorOccurred()) {
goto overflow;
}

result = ui;
return true;

Expand Down
5 changes: 4 additions & 1 deletion pythonnet/src/tests/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ def main(verbosity=1):
module = __import__(name)
suite.addTests((module.test_suite(),))

unittest.TextTestRunner(verbosity=verbosity).run(suite)
result = unittest.TextTestRunner(verbosity=verbosity).run(suite)
if not result.wasSuccessful():
raise Exception("Tests failed")

if __name__ == '__main__':
main(1)
if '--pause' in sys.argv:
print "Press enter to continue"
raw_input()