#NEWLINE# def in_test( self , expr , full , set ) : #NEWLINE# #INDENT# "Generate a test of (expr) being in (set), where (set) is a subset of (full)\n\n        expr is a string (Python expression)\n        set is a list of values (which will be converted with repr)\n        full is the list of all values expr could possibly evaluate to\n\n        >>> t = Generator('', [], [], [])\n        >>> t.in_test('x', [1,2,3,4], [])\n        '0'\n        >>> t.in_test('x', [1,2,3,4], [1,2,3,4])\n        '1'\n        >>> t.in_test('x', [1,2,3,4], [1])\n        'x == 1'\n        >>> t.in_test('a+b', [1,2,3,4], [1,2])\n        'a+b in [1, 2]'\n        >>> t.in_test('x', [1,2,3,4,5], [1,2,3])\n        'x not in [4, 5]'\n        >>> t.in_test('x', [1,2,3,4,5], [1,2,3,4])\n        'x != 5'\n        " #NEWLINE# if ( not set ) : #NEWLINE# #INDENT# return '0' #NEWLINE# #UNINDENT# if ( len ( set ) == 1 ) : #NEWLINE# #INDENT# return ( '%s == %s' % ( expr , repr ( set [ 0 ] ) ) ) #NEWLINE# #UNINDENT# if ( full and ( len ( set ) > ( len ( not_set ) / 2 ) ) ) : #NEWLINE# #INDENT# not_set = [ x for x in full if ( x not in set ) ] #NEWLINE# return self . not_in_test ( expr , full , not_set ) #NEWLINE# #UNINDENT# return ( '%s in %s' % ( expr , repr ( set ) ) )