<s> """<STR_LIT>""" <EOL> import logging <EOL> import os <EOL> import re <EOL> import tempfile <EOL> import unittest <EOL> from google . cloud . dataflow . examples . complete . juliaset . juliaset import juliaset <EOL> class JuliaSetTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . test_files = { } <EOL> self . test_files [ '<STR_LIT>' ] = self . generate_temp_file ( ) <EOL> self . test_files [ '<STR_LIT>' ] = self . generate_temp_file ( ) <EOL> def tearDown ( self ) : <EOL> for test_file in self . test_files . values ( ) : <EOL> if os . path . exists ( test_file ) : <EOL> os . remove ( test_file ) <EOL> def generate_temp_file ( self ) : <EOL> with tempfile . NamedTemporaryFile ( delete = False ) as temp_file : <EOL> return temp_file . name <EOL> def run_example ( self , grid_size , image_file_name = None ) : <EOL> args = [ <EOL> '<STR_LIT>' % self . test_files [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' % grid_size , <EOL> ] <EOL> if image_file_name is not None : <EOL> args . append ( '<STR_LIT>' % image_file_name ) <EOL> juliaset . run ( args ) <EOL> def test_output_file_format ( self ) : <EOL> grid_size = <NUM_LIT:5> <EOL> self . run_example ( grid_size ) <EOL> with open ( self . test_files [ '<STR_LIT>' ] ) as result_file : <EOL> output_lines = result_file . readlines ( ) <EOL> self . assertEqual ( grid_size , len ( output_lines ) ) <EOL> for line in output_lines : <EOL> coordinates = re . findall ( r'<STR_LIT>' , line ) <EOL> self . assertTrue ( coordinates ) <EOL> self . assertEqual ( grid_size , len ( coordinates ) ) <EOL> def test_generate_fractal_image ( self ) : <EOL> temp_image_file = self . test_files [ '<STR_LIT>' ] <EOL> self . run_example ( <NUM_LIT:10> , image_file_name = temp_image_file ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> logging . getLogger ( ) . setLevel ( logging . INFO ) <EOL> unittest . main ( ) </s>
