<s> from unittest import TestCase <EOL> from unittest import skipIf <EOL> from lintreview . review import Problems <EOL> from lintreview . review import Comment <EOL> from lintreview . tools . eslint import Eslint <EOL> from lintreview . utils import in_path <EOL> from lintreview . utils import npm_exists <EOL> from nose . tools import eq_ <EOL> eslint_missing = not ( in_path ( '<STR_LIT>' ) or npm_exists ( '<STR_LIT>' ) ) <EOL> FILE_WITH_NO_ERRORS = '<STR_LIT>' , <EOL> FILE_WITH_ERRORS = '<STR_LIT>' <EOL> class TestEslint ( TestCase ) : <EOL> needs_eslint = skipIf ( eslint_missing , '<STR_LIT>' ) <EOL> def setUp ( self ) : <EOL> self . problems = Problems ( ) <EOL> options = { <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> self . tool = Eslint ( self . problems , options ) <EOL> def test_match_file ( self ) : <EOL> self . assertFalse ( self . tool . match_file ( '<STR_LIT>' ) ) <EOL> self . assertFalse ( self . tool . match_file ( '<STR_LIT>' ) ) <EOL> self . assertFalse ( self . tool . match_file ( '<STR_LIT>' ) ) <EOL> self . assertTrue ( self . tool . match_file ( '<STR_LIT>' ) ) <EOL> self . assertTrue ( self . tool . match_file ( '<STR_LIT>' ) ) <EOL> @ needs_eslint <EOL> def test_check_dependencies ( self ) : <EOL> self . assertTrue ( self . tool . check_dependencies ( ) ) <EOL> @ needs_eslint <EOL> def test_process_files_pass ( self ) : <EOL> self . tool . process_files ( FILE_WITH_NO_ERRORS ) <EOL> eq_ ( [ ] , self . problems . all ( FILE_WITH_NO_ERRORS ) ) <EOL> @ needs_eslint <EOL> def test_process_files_fail ( self ) : <EOL> self . tool . process_files ( [ FILE_WITH_ERRORS ] ) <EOL> problems = self . problems . all ( FILE_WITH_ERRORS ) <EOL> eq_ ( <NUM_LIT:2> , len ( problems ) ) <EOL> msg = ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> expected = Comment ( FILE_WITH_ERRORS , <NUM_LIT:2> , <NUM_LIT:2> , msg ) <EOL> eq_ ( expected , problems [ <NUM_LIT:0> ] ) <EOL> msg = ( "<STR_LIT>" ) <EOL> expected = Comment ( FILE_WITH_ERRORS , <NUM_LIT:4> , <NUM_LIT:4> , msg ) <EOL> eq_ ( expected , problems [ <NUM_LIT:1> ] ) <EOL> @ needs_eslint <EOL> def test_process_files_with_no_config ( self ) : <EOL> tool = Eslint ( self . problems , options = { } ) <EOL> tool . process_files ( [ FILE_WITH_ERRORS ] ) <EOL> problems = self . problems . all ( FILE_WITH_ERRORS ) <EOL> eq_ ( <NUM_LIT:0> , len ( problems ) , '<STR_LIT>' ) <EOL> @ needs_eslint <EOL> def test_process_files_with_config ( self ) : <EOL> options = { <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> tool = Eslint ( self . problems , options ) <EOL> tool . process_files ( [ FILE_WITH_ERRORS ] ) <EOL> problems = self . problems . all ( FILE_WITH_ERRORS ) <EOL> msg = ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> expected = [ Comment ( FILE_WITH_ERRORS , <NUM_LIT:2> , <NUM_LIT:2> , msg ) ] <EOL> eq_ ( expected , problems ) </s>
