<s> import os <EOL> import unittest <EOL> from click . testing import CliRunner <EOL> from pyq . pyq import main <EOL> def pjoin ( * path ) : <EOL> return os . path . join ( os . path . dirname ( __file__ ) , * path ) <EOL> class TestASTMatchEngine ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . runner = CliRunner ( ) <EOL> self . currentdir = os . getcwd ( ) <EOL> os . chdir ( pjoin ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def tearDown ( self ) : <EOL> os . chdir ( self . currentdir ) <EOL> def invoke ( self , * args ) : <EOL> return self . runner . invoke ( * args , catch_exceptions = False ) <EOL> def test_noargs ( self ) : <EOL> result = self . invoke ( main , [ ] ) <EOL> self . assertNotEqual ( result . exit_code , <NUM_LIT:0> ) <EOL> self . assertIn ( '<STR_LIT>' , result . output_bytes ) <EOL> def test_nodir ( self ) : <EOL> result = self . invoke ( main , [ '<STR_LIT>' ] ) <EOL> output = result . output_bytes . splitlines ( ) <EOL> self . assertEqual ( result . exit_code , <NUM_LIT:0> ) <EOL> self . assertEqual ( len ( output ) , <NUM_LIT:4> ) <EOL> self . assertEqual ( output [ <NUM_LIT:0> ] , '<STR_LIT>' ) <EOL> self . assertEqual ( output [ <NUM_LIT:1> ] , '<STR_LIT>' ) <EOL> self . assertEqual ( output [ <NUM_LIT:2> ] , '<STR_LIT>' ) <EOL> self . assertEqual ( output [ <NUM_LIT:3> ] , '<STR_LIT>' ) <EOL> def test_notpyfile ( self ) : <EOL> result = self . invoke ( main , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . assertEqual ( result . exit_code , <NUM_LIT:0> ) <EOL> def test_file ( self ) : <EOL> result = self . invoke ( main , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> output = result . output_bytes . splitlines ( ) <EOL> self . assertEqual ( result . exit_code , <NUM_LIT:0> ) <EOL> self . assertEqual ( output [ <NUM_LIT:0> ] , '<STR_LIT>' ) <EOL> def test_wildcard ( self ) : <EOL> result = self . invoke ( main , [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> output = result . output_bytes . splitlines ( ) <EOL> self . assertEqual ( result . exit_code , <NUM_LIT:0> ) <EOL> self . assertEqual ( len ( output ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( output [ <NUM_LIT:0> ] , '<STR_LIT>' ) <EOL> self . assertEqual ( output [ <NUM_LIT:1> ] , '<STR_LIT>' ) <EOL> self . assertEqual ( output [ <NUM_LIT:2> ] , '<STR_LIT>' ) <EOL> def test_print_filenames ( self ) : <EOL> result = self . invoke ( main , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> output = result . output_bytes . splitlines ( ) <EOL> self . assertEqual ( result . exit_code , <NUM_LIT:0> ) <EOL> self . assertEqual ( output [ <NUM_LIT:0> ] , '<STR_LIT>' ) <EOL> self . assertEqual ( output [ <NUM_LIT:1> ] , '<STR_LIT>' ) <EOL> def test_ignoredir ( self ) : <EOL> r = self . invoke ( main , [ '<STR_LIT>' , '<STR_LIT:class>' ] ) <EOL> output = r . output_bytes . splitlines ( ) <EOL> self . assertEqual ( r . exit_code , <NUM_LIT:0> ) <EOL> self . assertTrue ( any ( '<STR_LIT>' in p for p in output ) ) <EOL> r = self . invoke ( main , [ '<STR_LIT>' , '<STR_LIT:class>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> output = r . output_bytes . splitlines ( ) <EOL> self . assertEqual ( r . exit_code , <NUM_LIT:0> ) <EOL> self . assertFalse ( any ( '<STR_LIT>' in p for p in output ) ) <EOL> def test_ignoredir_norecurse ( self ) : <EOL> r = self . invoke ( main , [ '<STR_LIT>' , '<STR_LIT:class>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> output = r . output_bytes . splitlines ( ) <EOL> self . assertEqual ( r . exit_code , <NUM_LIT:0> ) <EOL> self . assertFalse ( any ( '<STR_LIT>' in p for p in output ) ) <EOL> r = self . invoke ( main , [ '<STR_LIT>' , '<STR_LIT:class>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) <EOL> output = r . output_bytes . splitlines ( ) <EOL> self . assertEqual ( r . exit_code , <NUM_LIT:0> ) <EOL> self . assertTrue ( any ( '<STR_LIT>' in p for p in output ) ) <EOL> def test_expand_matches ( self ) : <EOL> r1 = self . invoke ( main , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> r2 = self . invoke ( main , [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> r3 = self . invoke ( main , [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> output1 = r1 . output_bytes . splitlines ( ) <EOL> output2 = r2 . output_bytes . splitlines ( ) <EOL> output3 = r3 . output_bytes . splitlines ( ) <EOL> self . assertEqual ( r1 . exit_code , <NUM_LIT:0> ) <EOL> self . assertEqual ( len ( output1 ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( output1 [ <NUM_LIT:0> ] , '<STR_LIT>' ) <EOL> self . assertEqual ( r2 . exit_code , <NUM_LIT:0> ) <EOL> self . assertEqual ( len ( output2 ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( output2 [ <NUM_LIT:0> ] , '<STR_LIT>' ) <EOL> self . assertEqual ( output2 [ <NUM_LIT:1> ] , '<STR_LIT>' ) <EOL> self . assertEqual ( r3 . exit_code , <NUM_LIT:0> ) <EOL> self . assertEqual ( len ( output3 ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( output3 [ <NUM_LIT:0> ] , '<STR_LIT>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
