def test_bool_conversion(): """Test bool conversion.""" ob = ConversionTest() assert ob.BooleanField is False assert ob.BooleanField == 0 ob.BooleanField = True assert ob.BooleanField is True assert ob.BooleanField == 1 ob.BooleanField = False assert ob.BooleanField is False assert ob.BooleanField == 0 with pytest.raises(TypeError): ob.BooleanField = 1 with pytest.raises(TypeError): ob.BooleanField = 0 with pytest.raises(TypeError): ob.BooleanField = None with pytest.raises(TypeError): ob.BooleanField = '' with pytest.raises(TypeError): ob.BooleanField = System.Boolean(0) with pytest.raises(TypeError): ob.BooleanField = System.Boolean(1) with pytest.raises(TypeError): ob.BooleanField = System.Boolean('a')
def test_bool_conversion(): """Test bool conversion.""" ob = ConversionTest() assert ob.BooleanField is False assert ob.BooleanField is False assert ob.BooleanField == 0 ob.BooleanField = True assert ob.BooleanField is True assert ob.BooleanField is True assert ob.BooleanField == 1 ob.BooleanField = False assert ob.BooleanField is False assert ob.BooleanField is False assert ob.BooleanField == 0 ob.BooleanField = 1 assert ob.BooleanField is True assert ob.BooleanField is True assert ob.BooleanField == 1 ob.BooleanField = 0 assert ob.BooleanField is False assert ob.BooleanField is False assert ob.BooleanField == 0 ob.BooleanField = System.Boolean(None) assert ob.BooleanField is False assert ob.BooleanField is False assert ob.BooleanField == 0 ob.BooleanField = System.Boolean('') assert ob.BooleanField is False assert ob.BooleanField is False assert ob.BooleanField == 0 ob.BooleanField = System.Boolean(0) assert ob.BooleanField is False assert ob.BooleanField is False assert ob.BooleanField == 0 ob.BooleanField = System.Boolean(1) assert ob.BooleanField is True assert ob.BooleanField is True assert ob.BooleanField == 1 ob.BooleanField = System.Boolean('a') assert ob.BooleanField is True assert ob.BooleanField is True assert ob.BooleanField == 1
def testBoolConversion(self): """Test bool conversion.""" object = ConversionTest() self.failUnless(object.BooleanField == False) self.failUnless(object.BooleanField is False) self.failUnless(object.BooleanField == 0) object.BooleanField = True self.failUnless(object.BooleanField == True) self.failUnless(object.BooleanField is True) self.failUnless(object.BooleanField == 1) object.BooleanField = False self.failUnless(object.BooleanField == False) self.failUnless(object.BooleanField is False) self.failUnless(object.BooleanField == 0) object.BooleanField = 1 self.failUnless(object.BooleanField == True) self.failUnless(object.BooleanField is True) self.failUnless(object.BooleanField == 1) object.BooleanField = 0 self.failUnless(object.BooleanField == False) self.failUnless(object.BooleanField is False) self.failUnless(object.BooleanField == 0) object.BooleanField = System.Boolean(None) self.failUnless(object.BooleanField == False) self.failUnless(object.BooleanField is False) self.failUnless(object.BooleanField == 0) object.BooleanField = System.Boolean('') self.failUnless(object.BooleanField == False) self.failUnless(object.BooleanField is False) self.failUnless(object.BooleanField == 0) object.BooleanField = System.Boolean(0) self.failUnless(object.BooleanField == False) self.failUnless(object.BooleanField is False) self.failUnless(object.BooleanField == 0) object.BooleanField = System.Boolean(1) self.failUnless(object.BooleanField == True) self.failUnless(object.BooleanField is True) self.failUnless(object.BooleanField == 1) object.BooleanField = System.Boolean('a') self.failUnless(object.BooleanField == True) self.failUnless(object.BooleanField is True) self.failUnless(object.BooleanField == 1)
def test_primitive_inheritance(): import System def InheritFromType(t): class InheritedType(t): pass return InheritedType AssertError(TypeError, InheritFromType, System.Int64) AssertError(TypeError, InheritFromType, System.Boolean) # isinstance Assert(isinstance(System.Int64(), System.Int64) == True) Assert(isinstance(System.Boolean(), System.Boolean) == True) Assert(isinstance(1, System.Int64) == False) Assert(isinstance(1, System.Boolean) == False) class userClass(object): pass Assert(isinstance(userClass(), System.Int64) == False) Assert(isinstance(userClass(), System.Boolean) == False) # issubclass Assert(issubclass(System.Int64, System.Int64) == True) Assert(issubclass(System.Boolean, System.Boolean) == True) Assert(issubclass(type(1), System.Int64) == False) Assert(issubclass(type(1), System.Boolean) == False) Assert(issubclass(userClass, System.Int64) == False) Assert(issubclass(userClass, System.Boolean) == False)
def create(sequence_path, target, parameters, debug, timeout): """ Creates an instance of niveristand.clientapi._sequencecallinfo._SequenceCallInfo class. Args: sequence_path (str): The file path of the sequence file to execute. target (str): The name of the target on which to execute the sequence. parameters (list[niveristand.clientapi._sequenceparameterassignmentinfo._SequenceParameterAssignmentInfo]): The parameter assignments for the sequence. debug (bool): Whether the sequence executes in debug mode. timeout (float): The timeout in milliseconds within which the sequence must complete each time step. Returns: niveristand.clientapi._sequencecallinfo._SequenceCallInfo: Newly created instance. """ if target is None: target = "" target = System.String(target) sequence_path = System.String(sequence_path) debug = System.Boolean(debug) timeout = System.Double(timeout) parameters_dot_net = [ parameter.dot_net_instance for parameter in parameters ] parameters_dot_net_array = System.Array[ SequenceParameterAssignmentInfo](parameters_dot_net) sequence_call_info_dot_net = \ SequenceCallInfoDotNet(sequence_path, target, parameters_dot_net_array, debug, timeout) sequence_call_info = _SequenceCallInfo(sequence_call_info_dot_net) return sequence_call_info
def ReconnectToSystem(self, target, deploy, calibration_file, timeout): """Reconnects the VeriStand Gateway to a target within the system definition file used by the Gateway.\ You can also redeploy the system definition file.""" options = DeployOptions() options.DeploySystemDefinition = System.Boolean(deploy) options.Timeout = timeout options.CalibratonFilePath = calibration_file _RaiseException_( self.iwks.ReconnectToSystem(System.String(target), options))
def GetAlarmsStatus(self): """Acquires a list of alarms organized by status (high, medium, and low).""" a0 = a1 = a2 = System.Boolean(False) aname0 = aname1 = aname2 = System.String('') data = self.iamgr.GetAlarmsStatus(a0, a1, a2, aname0, aname1, aname2) _RaiseException_(data[0]) return { 'HighAlarm': data[1], 'MediumAlarm': data[2], 'LowAlarm': data[3], 'HighAlarmName': data[4], 'MedAlarmName': data[5], 'LowAlarmName': data[6] }
def ConnectToSystem(self, systemdefinition_file, deploy, timeout): """Connects the VeriStand Gateway to one or more targets running on the System Definition file you specify.""" _RaiseException_( self.iwks.ConnectToSystem(systemdefinition_file, System.Boolean(deploy), System.UInt32(timeout)))
def test_pep3141(): ''' This is already well covered by CPython's test_abstract_numbers.py. Just check a few .NET interop cases as well to see what happens. ''' import System from numbers import Complex, Real, Rational, Integral, Number #--Complex for x in [ System.Double(9), System.Int32(4), System.Boolean(1), ]: Assert(isinstance(x, Complex)) for x in [ #http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=23147 System.Char.MaxValue, System.Single(8), System.Decimal(10), System.SByte(0), System.Byte(1), System.Int16(2), System.UInt16(3), System.UInt32(5), System.Int64(6), System.UInt64(7), ]: Assert(not isinstance(x, Complex), x) #--Real for x in [ System.Double(9), System.Int32(4), System.Boolean(1), ]: Assert(isinstance(x, Real)) for x in [ #http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=23147 System.Char.MaxValue, System.Single(8), System.Decimal(10), System.SByte(0), System.Byte(1), System.Int16(2), System.UInt16(3), System.UInt32(5), System.Int64(6), System.UInt64(7), ]: Assert(not isinstance(x, Real)) #--Rational for x in [ System.Int32(4), System.Boolean(1), ]: Assert(isinstance(x, Rational)) for x in [ System.Double(9), #http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=23147 System.Char.MaxValue, System.Single(8), System.Decimal(10), System.SByte(0), System.Byte(1), System.Int16(2), System.UInt16(3), System.UInt32(5), System.Int64(6), System.UInt64(7), ]: Assert(not isinstance(x, Rational)) #--Integral for x in [ System.Int32(4), System.Boolean(1), ]: Assert(isinstance(x, Integral)) for x in [ System.Double(9), #http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=23147 System.Char.MaxValue, System.Single(8), System.Decimal(10), System.SByte(0), System.Byte(1), System.Int16(2), System.UInt16(3), System.UInt32(5), System.Int64(6), System.UInt64(7), ]: Assert(not isinstance(x, Integral)) #--Number for x in [ System.Double(9), System.Int32(4), System.Boolean(1), ]: Assert(isinstance(x, Number)) for x in [ #http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=23147 System.Char.MaxValue, System.Single(8), System.Decimal(10), System.SByte(0), System.Byte(1), System.Int16(2), System.UInt16(3), System.UInt32(5), System.Int64(6), System.UInt64(7), ]: Assert(not isinstance(x, Number))