<s> from __future__ import ( absolute_import , division , generators , nested_scopes , print_function , <EOL> unicode_literals , with_statement ) <EOL> import os <EOL> from textwrap import dedent <EOL> from pants . backend . graph_info . tasks . listtargets import ListTargets <EOL> from pants . backend . jvm . artifact import Artifact <EOL> from pants . backend . jvm . repository import Repository <EOL> from pants . backend . jvm . scala_artifact import ScalaArtifact <EOL> from pants . backend . jvm . targets . java_library import JavaLibrary <EOL> from pants . backend . python . targets . python_library import PythonLibrary <EOL> from pants . build_graph . build_file_aliases import BuildFileAliases <EOL> from pants . build_graph . target import Target <EOL> from pants_test . tasks . task_test_base import ConsoleTaskTestBase <EOL> class BaseListTargetsTest ( ConsoleTaskTestBase ) : <EOL> @ classmethod <EOL> def task_type ( cls ) : <EOL> return ListTargets <EOL> class ListTargetsTestEmpty ( BaseListTargetsTest ) : <EOL> def test_list_all_empty ( self ) : <EOL> self . assertEqual ( '<STR_LIT>' , self . execute_task ( ) ) <EOL> self . assertEqual ( '<STR_LIT>' , self . execute_task ( options = { '<STR_LIT>' : '<STR_LIT>' } ) ) <EOL> self . assertEqual ( [ ] , self . execute_console_task ( ) ) <EOL> class ListTargetsTest ( BaseListTargetsTest ) : <EOL> @ property <EOL> def alias_groups ( self ) : <EOL> return BuildFileAliases ( <EOL> targets = { <EOL> '<STR_LIT:target>' : Target , <EOL> '<STR_LIT>' : JavaLibrary , <EOL> '<STR_LIT>' : PythonLibrary , <EOL> } , <EOL> objects = { <EOL> '<STR_LIT>' : lambda x : x , <EOL> '<STR_LIT>' : Artifact , <EOL> '<STR_LIT>' : ScalaArtifact , <EOL> '<STR_LIT>' : Repository ( name = '<STR_LIT>' , <EOL> url = '<STR_LIT>' , <EOL> push_db_basedir = '<STR_LIT>' ) , <EOL> } <EOL> ) <EOL> def setUp ( self ) : <EOL> super ( ListTargetsTest , self ) . setUp ( ) <EOL> class Lib ( object ) : <EOL> def __init__ ( self , name , provides = False ) : <EOL> self . name = name <EOL> self . provides = dedent ( """<STR_LIT>""" . format ( name ) ) . strip ( ) if provides else '<STR_LIT:None>' <EOL> def create_library ( path , * libs ) : <EOL> libs = libs or [ Lib ( os . path . basename ( os . path . dirname ( self . build_path ( path ) ) ) ) ] <EOL> for lib in libs : <EOL> target = "<STR_LIT>" . format ( <EOL> name = lib . name , provides = lib . provides ) <EOL> self . add_to_build_file ( path , target ) <EOL> create_library ( '<STR_LIT:a>' ) <EOL> create_library ( '<STR_LIT>' , Lib ( '<STR_LIT:b>' , provides = True ) ) <EOL> create_library ( '<STR_LIT>' , Lib ( '<STR_LIT:c>' ) , Lib ( '<STR_LIT>' , provides = True ) , Lib ( '<STR_LIT>' ) ) <EOL> create_library ( '<STR_LIT>' ) <EOL> create_library ( '<STR_LIT>' , Lib ( '<STR_LIT>' ) ) <EOL> self . add_to_build_file ( '<STR_LIT:f>' , dedent ( '''<STR_LIT>''' ) ) <EOL> def test_list_path ( self ) : <EOL> self . assert_console_output ( '<STR_LIT>' , targets = [ self . target ( '<STR_LIT>' ) ] ) <EOL> def test_list_siblings ( self ) : <EOL> self . assert_console_output ( '<STR_LIT>' , targets = self . targets ( '<STR_LIT>' ) ) <EOL> self . assert_console_output ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> targets = self . targets ( '<STR_LIT>' ) ) <EOL> def test_list_descendants ( self ) : <EOL> self . assert_console_output ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> targets = self . targets ( '<STR_LIT>' ) ) <EOL> self . assert_console_output ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> targets = self . targets ( '<STR_LIT>' ) ) <EOL> def test_list_all ( self ) : <EOL> self . assert_entries ( '<STR_LIT:\n>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> self . assert_entries ( '<STR_LIT:U+002CU+0020>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> options = { '<STR_LIT>' : '<STR_LIT:U+002CU+0020>' } ) <EOL> self . assert_console_output ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> def test_list_provides ( self ) : <EOL> self . assert_console_output ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> options = { '<STR_LIT>' : True } ) <EOL> def test_list_provides_customcols ( self ) : <EOL> self . assert_console_output ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> options = { '<STR_LIT>' : True , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> ) <EOL> def test_list_dedups ( self ) : <EOL> targets = [ ] <EOL> targets . extend ( self . targets ( '<STR_LIT>' ) ) <EOL> targets . extend ( self . target ( '<STR_LIT>' ) . dependencies ) <EOL> self . assertEquals ( <NUM_LIT:3> , len ( targets ) , "<STR_LIT>" ) <EOL> self . assert_console_output ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> targets = targets <EOL> ) <EOL> def test_list_documented ( self ) : <EOL> self . assert_console_output ( <EOL> targets = [ self . target ( '<STR_LIT>' ) ] , <EOL> options = { '<STR_LIT>' : True } , <EOL> ) <EOL> self . assert_console_output ( <EOL> dedent ( """<STR_LIT>""" ) . strip ( ) , <EOL> options = { '<STR_LIT>' : True } <EOL> ) <EOL> def test_no_synthetic_resources_in_output ( self ) : <EOL> self . add_to_build_file ( '<STR_LIT>' , dedent ( """<STR_LIT>""" ) ) <EOL> output = self . execute_console_task ( ) <EOL> self . assertIn ( '<STR_LIT>' , output ) <EOL> self . assertTrue ( all ( '<STR_LIT>' not in line for line in output ) ) </s>
