1from PyObjCTools.TestSupport import * 2from PyObjCTest.testhelper import PyObjC_TestClass3 3from Foundation import NSHost 4 5class TestNSHost (TestCase): 6 def testCreation(self): 7 # 8 # This gives an exception on GNUstep: 9 # NSRecursiveLockException - unlock: failed to unlock mutex 10 # 11 # testIndirectCreation performs the same operation from Objective-C 12 # and doesn't fail. I don't see any significant differences in the 13 # implementation of -hostWithAddress: and -hostWithName: yet the latter 14 # does not have the problem we're seeing here. 15 # 16 o = NSHost.hostWithAddress_(u'127.0.0.1') 17 self.assertEqual(o.addresses(), (u'127.0.0.1',)) 18 self.assertEqual(o.address(), u'127.0.0.1') 19 20 def testCreation2(self): 21 o = NSHost.hostWithName_(u'localhost') 22 l = list(o.addresses()) 23 l.sort() 24 #self.assert_(l in ([u'127.0.0.1', u'::1'], [u'127.0.0.1'])) 25 self.assertEqual(o.address(), o.addresses()[0]) 26 27 def testIndirectCreation(self): 28 o = PyObjC_TestClass3.createAHostWithAddress_(u'127.0.0.1') 29 self.assertEqual(o.address(), u'127.0.0.1') 30 31 def testMethods(self): 32 self.assertArgIsBOOL(NSHost.setHostCacheEnabled_, 0) 33 self.assertResultIsBOOL(NSHost.isHostCacheEnabled) 34 self.assertResultIsBOOL(NSHost.isEqualToHost_) 35 36if __name__ == "__main__": 37 main() 38