8000 Fixed #296 Converter support for PyObject by rmadsen-ks · Pull Request #297 · pythonnet/pythonnet · GitHub
[go: up one dir, main page]

Skip to content

Fixed #296 Converter support for PyObject #297

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 7 commits into from
Dec 16, 2016
Merged
Changes from 2 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
54 changes: 52 additions & 2 deletions src/tests/test_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import Python.Test as Test
import System
import six
import Python.Runtime
from Python.Test import ClassTest
from System.Collections import Hashtable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was not needed by me, but it seems I had added a windows line-ending. Its fixed now.


if six.PY3:
DictProxyType = type(object.__dict__)
Expand Down Expand Up @@ -200,6 +201,55 @@ def __setitem__(self, key, value):

self.assertTrue(table.Count == 3)

def testAddAndRemoveClassAttribute(self):

from System import TimeSpan

for i in range(100):
TimeSpan.new_method = lambda self: self.TotalMinutes
ts = TimeSpan.FromHours(1)
self.assertTrue(ts.new_method() == 60)
del TimeSpan.new_method
self.assertFalse(hasattr(ts, "new_method"))

def testComparisons(self):
from System import DateTimeOffset

d1 = DateTimeOffset.Parse("2016-11-14")
d2 = DateTimeOffset.Parse("2016-11-15")

self.assertEqual(d1 == d2, False)
self.assertEqual(d1 != d2, True)

self.assertEqual(d1 < d2, True)
self.assertEqual(d1 <= d2, True)
self.assertEqual(d1 >= d2, False)
self.assertEqual(d1 > d2, False)

self.assertEqual(d1 == d1, True)
self.assertEqual(d1 != d1, False)

self.assertEqual(d1 < d1, False)
self.assertEqual(d1 <= d1, True)
self.assertEqual(d1 >= d1, True)
self.assertEqual(d1 > d1, False)

self.assertEqual(d2 == d1, False)
self.assertEqual(d2 != d1, True)

self.assertEqual(d2 < d1, False)
self.assertEqual(d2 <= d1, False)
self.assertEqual(d2 >= d1, True)
self.assertEqual(d2 > d1, True)

self.assertRaises(TypeError, lambda: d1 < None)
self.assertRaises(TypeError, lambda: d1 < System.Guid())

# ClassTest does not implement IComparable
c1 = ClassTest()
c2 = ClassTest()
self.assertRaises(TypeError, lambda: c1 < c2)

def testSelfCallback(self):
""" Test calling back and forth between this and a c# baseclass."""
class CallbackUser(Test.SelfCallbackTest):
Expand All @@ -214,7 +264,7 @@ def PyCallback(self, self2):
testobj = CallbackUser()
testobj.DoCallback()
self.assertTrue(testobj.PyCallbackWasCalled)
self.assertTrue(testobj.SameReference)
self.assertTrue(testobj.SameReference)

class ClassicClass:
def kind(self):
Expand Down
0