def needs_wildcard_target_identifier (_test, qualified_member = 'qualified_target', wildcard_member = 'wildcard_target', identifier = None, length = 8, part_length = 8) :
	
	def _constructor () :
		_qualified_identifier = identifier if identifier is not None else [uuid.uuid4 () .hex [:part_length] for _index in xrange (length)]
		_wildcard_identifier = list (_qualified_identifier)
		_available_count = len (_wildcard_identifier)
		_wildcards_count = random.randint (1, 3)
		assert _available_count >= 4
		while True :
			if random.random () < 0.75 :
				_wildcard_index = random.randint (0, len (_wildcard_identifier) - 1)
				if _wildcard_identifier[_wildcard_index] == '*' or _wildcard_identifier[_wildcard_index] == '**' :
					continue
				if _available_count <= 1 :
					break
				_wildcard_identifier[_wildcard_index] = '*'
				_wildcards_count -= 1
				_available_count -= 1
			else :
				_wildcard_index = random.randint (0, len (_wildcard_identifier) - 2)
				if _wildcard_identifier[_wildcard_index] == '*' or _wildcard_identifier[_wildcard_index] == '**' :
					continue
				if _available_count <= 2 :
					break
				_wildcard_identifier[_wildcard_index] = '**'
				del _wildcard_identifier[_wildcard_index + 1]
				_wildcards_count -= 1
				_available_count -= 2
			if _wildcards_count == 0 :
				break
		return _qualified_identifier, _wildcard_identifier
	
	return testing.append_context_members_hook (_test, (qualified_member, wildcard_member), _constructor, None)
def needs_pipe_task (_test, input_source_member = 'input_source', input_sink_member = 'input_sink', input_callback_member = 'input_callback', output_source_member = 'output_source', output_sink_member = 'output_sink', output_callback_member = 'output_callback', input_done_member = 'input_done', output_done_member = 'output_done', data = None) :
	
	def _constructor () :
		_data = data
		if _data is None : _data = 128
		if type (_data) is int :
			_data = ''.join ([''.join ([chr (random.randint (32, 127)) for _index in xrange (_data)]) * 1024])
		_total = len (_data)
		_input_source, _output_sink = os.pipe ()
		_input_sink = stringio.StringIO ('')
		_output_source = stringio.StringIO (_data)
		_input_state = [False, 0]
		_output_state = [False, 0]
		_input_done = threading.Event ()
		_output_done = threading.Event ()
		def _input_callback (_event) :
			if _event is reactor._reactor_poll_events.close :
				assert not _input_state[0]
				_input_state[0] = True
			else :
				assert _event is reactor._reactor_poll_events.input
				_size = random.randint (1, 1024)
				_data = os.read (_input_source, _size)
				if _data != '' :
					_size = len (_data)
					_size_ = _input_sink.write (_data)
					assert _size_ is None
					_input_state[1] += _size
					if _input_state[1] == _total :
						_input_done.set ()
		def _output_callback (_event) :
			if _event is reactor._reactor_poll_events.close :
				assert not _output_state[0]
				_output_state[0] = True
			else :
				assert _event is reactor._reactor_poll_events.output
				_size = random.randint (1, 1024)
				_data = _output_source.read (_size)
				if _data != '' :
					_size = len (_data)
					_size_ = os.write (_output_sink, _data)
					assert _size_ <= _size
					if _size_ < _size :
						_output_source.seek (0 - (_size - _size_), os.SEEK_CUR)
						_size = _size_
					assert _size_ == _size
					_output_state[1] += _size
					if _output_state[1] == _total :
						_output_done.set ()
		return _input_source, _input_sink, _input_callback, _input_done, _output_source, _output_sink, _output_callback, _output_done
	
	def _destructor (_input_source, _input_sink, _input_callback, _input_done, _output_source, _output_sink, _output_callback, _output_done) :
		os.close (_input_source)
		os.close (_output_sink)
		_input_sink.close ()
		_output_source.close ()
	
	return testing.append_context_members_hook (_test, (input_source_member, input_sink_member, input_callback_member, input_done_member, output_source_member, output_sink_member, output_callback_member, output_done_member), _constructor, _destructor)
def needs_queue_handler (_test, queue_member = 'queue', handler_member = 'handler') :
	
	def _constructor () :
		_queue = queue.Queue ()
		def _handler (_session, _endpoint, _message) :
			_queue.put ((_endpoint, _message), False)
			return
		return _queue, _handler
	
	return testing.append_context_members_hook (_test, (queue_member, handler_member), _constructor, None)
def needs_enqueue_something_task (_test, queue = None, something = None, queue_member = 'queue', callback_member = 'callback', something_member = 'something') :
	
	if something is None : something = object ()
	
	def _constructor () :
		_queue = queue
		if _queue is None :
			_queue = Queue.Queue ()
		def _callback () :
			_queue.put (something, False)
			return None
		return _queue, _callback, something
	
	return testing.append_context_members_hook (_test, (queue_member, callback_member, something_member), _constructor, None)
def needs_port_queue_callback_server (_test, _class, _member, _session, _agent, _target_or_port, _coder, _queue, _auto_register, _auto_unregister) :
	
	if _auto_unregister is None : _auto_unregister = _auto_register
	
	def _constructor (__context = None, * __metadata) :
		_queue = queue.Queue ()
		def _callback (_message, _attributes) :
			_queue.put ((_message, _attributes), False)
			return
		_server = _construct_wrapper (_class, __context, _session, _agent, _target_or_port, _coder, _callback)
		_register_server (_server, _auto_register)
		return _server, _queue
	
	def _destructor (_server, _queue, __context = None, * __metadata) :
		_unregister_server (_server, _auto_unregister)
		return
	
	return testing.append_context_members_hook (_test, (_server_member, _queue_member), _constructor, _destructor, _accepts_metadata = True)