<s> '''<STR_LIT>''' <EOL> import datetime <EOL> import os <EOL> import sys <EOL> from tinkerer import paths , post <EOL> from tinkertest import utils <EOL> class TestPatch ( utils . BaseTinkererTest ) : <EOL> def check_posts ( self , filenames , posts , expected ) : <EOL> for filename in filenames : <EOL> with open ( os . path . join ( paths . root , filename ) , "<STR_LIT:w>" ) as f : <EOL> f . write ( "<STR_LIT>" ) <EOL> for new_post in posts : <EOL> post . create ( new_post [ <NUM_LIT:0> ] , datetime . date ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT:1> ) ) . write ( <EOL> content = new_post [ <NUM_LIT:1> ] <EOL> ) <EOL> self . build ( ) <EOL> for test in expected : <EOL> with open ( os . path . join ( paths . html , * test [ <NUM_LIT:0> ] ) , "<STR_LIT:r>" ) as f : <EOL> content = f . read ( ) <EOL> for data in test [ <NUM_LIT:1> ] : <EOL> if data not in content : <EOL> print ( data ) <EOL> print ( content ) <EOL> self . assertTrue ( data in content ) <EOL> def test_patch_a_and_img ( self ) : <EOL> filenames = [ "<STR_LIT>" ] <EOL> posts = [ <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> ] <EOL> expected = [ <EOL> ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ ( '<STR_LIT>' if sys . version_info [ <NUM_LIT:0> ] == <NUM_LIT:3> else <EOL> '<STR_LIT>' ) , <EOL> '<STR_LIT>' ] ) , <EOL> ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <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> '<STR_LIT>' ] ) <EOL> ] <EOL> self . check_posts ( filenames , posts , expected ) <EOL> def test_patch_target ( self ) : <EOL> filenames = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> posts = [ <EOL> ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT:\n>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT:\n>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> ] <EOL> expected = [ <EOL> ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) , <EOL> ( [ "<STR_LIT>" ] , <EOL> [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) , <EOL> ( [ "<STR_LIT>" ] , <EOL> [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) <EOL> ] <EOL> self . check_posts ( filenames , posts , expected ) <EOL> def test_patch_bad_link ( self ) : <EOL> posts = [ <EOL> ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> ] <EOL> expected = [ <EOL> ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ] ) <EOL> ] <EOL> self . check_posts ( [ ] , posts , expected ) </s>
