<s> import pytest <EOL> from io import BytesIO <EOL> from thefuck . rules . git_checkout import match , get_branches , get_new_command <EOL> from tests . utils import Command <EOL> @ pytest . fixture <EOL> def did_not_match ( target , did_you_forget = False ) : <EOL> error = ( "<STR_LIT>" <EOL> "<STR_LIT>" . format ( target ) ) <EOL> if did_you_forget : <EOL> error = ( "<STR_LIT>" . format ( error ) ) <EOL> return error <EOL> @ pytest . fixture <EOL> def git_branch ( mocker , branches ) : <EOL> mock = mocker . patch ( '<STR_LIT>' ) <EOL> mock . return_value . stdout = BytesIO ( branches ) <EOL> return mock <EOL> @ pytest . mark . parametrize ( '<STR_LIT>' , [ <EOL> Command ( script = '<STR_LIT>' , stderr = did_not_match ( '<STR_LIT>' ) ) , <EOL> Command ( script = '<STR_LIT>' , stderr = did_not_match ( '<STR_LIT>' ) ) ] ) <EOL> def test_match ( command ) : <EOL> assert match ( command ) <EOL> @ pytest . mark . parametrize ( '<STR_LIT>' , [ <EOL> Command ( script = '<STR_LIT>' , <EOL> stderr = did_not_match ( '<STR_LIT>' , True ) ) , <EOL> Command ( script = '<STR_LIT>' , stderr = ( '<STR_LIT>' ) ) , <EOL> Command ( script = '<STR_LIT>' , stderr = ( '<STR_LIT>' ) ) ] ) <EOL> def test_not_match ( command ) : <EOL> assert not match ( command ) <EOL> @ pytest . mark . parametrize ( '<STR_LIT>' , [ <EOL> ( b'<STR_LIT>' , [ ] ) , <EOL> ( b'<STR_LIT>' , [ '<STR_LIT>' ] ) , <EOL> ( b'<STR_LIT>' , [ '<STR_LIT>' ] ) , <EOL> ( b'<STR_LIT>' , [ '<STR_LIT>' ] ) , <EOL> ( b'<STR_LIT>' , [ '<STR_LIT>' , '<STR_LIT>' ] ) , <EOL> ( b'<STR_LIT>' , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) ] ) <EOL> def test_get_branches ( branches , branch_list , git_branch ) : <EOL> git_branch ( branches ) <EOL> assert list ( get_branches ( ) ) == branch_list <EOL> @ pytest . mark . parametrize ( '<STR_LIT>' , [ <EOL> ( b'<STR_LIT>' , <EOL> Command ( script = '<STR_LIT>' , stderr = did_not_match ( '<STR_LIT>' ) ) , <EOL> '<STR_LIT>' ) , <EOL> ( b'<STR_LIT>' , <EOL> Command ( '<STR_LIT>' , stderr = did_not_match ( '<STR_LIT>' ) ) , <EOL> '<STR_LIT>' ) , <EOL> ( b'<STR_LIT>' , <EOL> Command ( script = '<STR_LIT>' , <EOL> stderr = did_not_match ( '<STR_LIT>' ) ) , <EOL> '<STR_LIT>' ) , <EOL> ( b'<STR_LIT>' , <EOL> Command ( script = '<STR_LIT>' , <EOL> stderr = did_not_match ( '<STR_LIT>' ) ) , <EOL> '<STR_LIT>' ) ] ) <EOL> def test_get_new_command ( branches , command , new_command , git_branch ) : <EOL> git_branch ( branches ) <EOL> assert get_new_command ( command ) == new_command </s>
