Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

get most of the unit tests working with mono#9

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
davidanthoff merged 1 commit intopythonnet:developfromtonyroberts:travis-ci
Feb 26, 2014
Merged
Show file tree
Hide file tree
Changes fromall 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
6 changes: 2 additions & 4 deletionspythonnet/src/monoclr/pynetinit.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -104,10 +104,8 @@ void main_thread_handler (gpointer user_data) {
for (ii = 0; ii < PyList_Size(syspath); ++ii) {
const char* pydir = PyString_AsString(PyList_GetItem(syspath, ii));
char* curdir = (char*) malloc(1024);
if (strlen(pydir) == 0) pydir = ".";

strcpy(curdir, pydir);
strcat(curdir, slash);
strncpy(curdir, strlen(pydir) > 0 ? pydir : ".", 1024);
strncat(curdir, slash, 1024);

//look in this directory for the pn_args->pr_file
DIR* dirp = opendir(curdir);
Expand Down
4 changes: 3 additions & 1 deletionpythonnet/src/runtime/runtime.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -77,9 +77,11 @@ internal static void Initialize() {

if (0 == Runtime.Py_IsInitialized()) {
Runtime.Py_Initialize();
Runtime.PyEval_InitThreads();
}

// make sure threads are initialized even if python was initialized already
Runtime.PyEval_InitThreads();

IntPtr dict = Runtime.PyImport_GetModuleDict();
IntPtr op = Runtime.PyDict_GetItemString(dict, "__builtin__");

Expand Down
5 changes: 2 additions & 3 deletionspythonnet/src/testing/constructortests.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,6 @@

using System;
using System.Collections;
using System.Windows.Forms;
using System.IO;

namespace Python.Test {
Expand DownExpand Up@@ -53,9 +52,9 @@ public StructConstructorTest(Guid v) {

public class SubclassConstructorTest {

publicControl value;
publicException value;

public SubclassConstructorTest(Control v) {
public SubclassConstructorTest(Exception v) {
this.value = v;
}

Expand Down
10 changes: 10 additions & 0 deletionspythonnet/src/testing/enumtest.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -88,4 +88,14 @@ public enum ULongEnum : ulong {
Five
}

[FlagsAttribute]
public enum FlagsEnum {
Zero,
One,
Two,
Three,
Four,
Five
}

}
1 change: 1 addition & 0 deletionspythonnet/src/testing/fieldtest.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -57,6 +57,7 @@ public void Shutup() {
public decimal DecimalField = 0;
public string StringField;
public ShortEnum EnumField;
public FlagsEnum FlagsField;
public object ObjectField;
public ISpam SpamField;

Expand Down
3 changes: 1 addition & 2 deletionspythonnet/src/testing/methodtest.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,6 @@

using System;
using System.IO;
using System.Windows.Forms;
using System.Collections.Generic;

namespace Python.Test {
Expand DownExpand Up@@ -71,7 +70,7 @@ public Guid TestStructConversion(Guid v) {
return v;
}

publicControl TestSubclassConversion(Control v) {
publicException TestSubclassConversion(Exception v) {
return v;
}

Expand Down
10 changes: 5 additions & 5 deletionspythonnet/src/tests/test_constructors.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,14 +49,14 @@ def testStructConstructor(self):
def testSubclassConstructor(self):
"""Test subclass constructor args"""
from Python.Test import SubclassConstructorTest
from System.Windows.Forms import Form, Control

class sub(Form):
class sub(System.Exception):
pass

form = sub()
ob = SubclassConstructorTest(form)
self.assertTrue(isinstance(ob.value, Control))
instance = sub()
ob = SubclassConstructorTest(instance)
print ob
self.assertTrue(isinstance(ob.value, System.Exception))



Expand Down
9 changes: 3 additions & 6 deletionspythonnet/src/tests/test_enum.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,16 +122,13 @@ def test():

def testEnumWithFlagsAttrConversion(self):
"""Test enumeration conversion with FlagsAttribute set."""
from System.Windows.Forms import Label

# This works because the AnchorStyles enum has FlagsAttribute.
label = Label()
label.Anchor = 99
# This works because the FlagsField enum has FlagsAttribute.
Test.FieldTest().FlagsField = 99

# This should fail because our test enum doesn't have it.
def test():
Test.FieldTest().EnumField = 99

self.assertRaises(ValueError, test)


Expand Down
7 changes: 0 additions & 7 deletionspythonnet/src/tests/test_event.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -493,7 +493,6 @@ def testRandomMultipleHandlers(self):

def testRemoveInternalCallHandler(self):
"""Test remove on an event sink implemented w/internalcall."""
clr.AddReference('System.Windows.Forms')
object = EventTest()

def h(sender, args):
Expand All@@ -502,12 +501,6 @@ def h(sender, args):
object.PublicEvent += h
object.PublicEvent -= h

from System.Windows.Forms import Form
f = Form()
f.Click += h
f.Click -= h
f.Dispose()


def testRemoveUnknownHandler(self):
"""Test removing an event handler that was never added."""
Expand Down
11 changes: 4 additions & 7 deletionspythonnet/src/tests/test_method.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -235,16 +235,13 @@ def testMethodCallStructConversion(self):

def testSubclassInstanceConversion(self):
"""Test subclass instance conversion in method call."""
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import Form, Control

class sub(Form):
class sub(System.Exception):
pass

object = MethodTest()
form = sub()
result = object.TestSubclassConversion(form)
self.assertTrue(isinstance(result,Control))
instance = sub()
result = object.TestSubclassConversion(instance)
self.assertTrue(isinstance(result,System.Exception))


def testNullArrayConversion(self):
Expand Down
3 changes: 3 additions & 0 deletionspythonnet/src/tests/test_module.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -204,6 +204,9 @@ def testFromModuleImportStar(self):

def testImplicitAssemblyLoad(self):
"""Test implicit assembly loading via import."""
# this test only applies to windows
if sys.platform != "win32":
return

def test():
# This should fail until System.Windows.Forms has been
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp