Merge pull request #599 from RobinD42/fix-issue595

Fix comparing DataViewItem with None
This commit is contained in:
Robin Dunn
2017-11-07 19:54:22 -06:00
committed by GitHub
2 changed files with 9 additions and 2 deletions

View File

@@ -84,8 +84,10 @@ def run():
c.addCppMethod('long', '__hash__', '()', """\
return (long)self->GetID();
""")
c.addCppMethod('bool', '__eq__', '(wxDataViewItem* other)', "return (self->GetID() == other->GetID());")
c.addCppMethod('bool', '__ne__', '(wxDataViewItem* other)', "return (self->GetID() != other->GetID());")
c.addCppMethod('bool', '__eq__', '(wxDataViewItem* other)',
"return other ? (self->GetID() == other->GetID()) : false;")
c.addCppMethod('bool', '__ne__', '(wxDataViewItem* other)',
"return other ? (self->GetID() != other->GetID()) : true;")
c.addAutoProperties()

View File

@@ -54,6 +54,11 @@ class dataview_Tests(wtc.WidgetTestCase):
self.assertTrue(int(dvi.GetID()) == n)
def test_dataviewItem8(self):
dvi = dv.DataViewItem(111)
assert (None == dvi) == False
assert (None != dvi) == True
#-------------------------------------------------------
def test_dataviewItemAttr1(self):