def test_attribute_set_to_value(self): """Test setting attribute to a value""" x = self.X() x.y = 1 assert 1 == x.y with attribute_set_to(x, 'y', 2): assert 2 == x.y assert 1 == x.y
def test_attribute_set_to_object(self): """Test setting attribute to an object""" x = self.X() original_object = self.X() x.y = original_object assert original_object == x.y assert original_object is x.y new_object = self.X() with attribute_set_to(x, 'y', new_object): assert new_object == x.y assert new_object is x.y assert original_object == x.y assert original_object is x.y
def _visa_resource_read_termination_set_to_none( visa_resource: pyvisa.Resource) -> ContextManager: """ This context manager works around the problem with 'query_binary_values' method in pyvisa 1.9.0 that results in visa timeout exception in drivers which use the method. Usage: ... # visa_resource is the variable that refers to the instrument's pyvisa # resource object with visa_query_binary_values_fix_for(visa_resource): visa_resource.query_binary_values(...) ... """ return attribute_set_to(visa_resource, '_read_termination', None)