<s> import unittest <EOL> from worldengine . plates import Step , center_land , world_gen <EOL> from worldengine . model . world import World <EOL> from tests . draw_test import TestBase <EOL> class TestGeneration ( TestBase ) : <EOL> def setUp ( self ) : <EOL> super ( TestGeneration , self ) . setUp ( ) <EOL> def test_world_gen_does_not_explode_badly ( self ) : <EOL> world_gen ( "<STR_LIT>" , <NUM_LIT:32> , <NUM_LIT:16> , <NUM_LIT:1> , step = Step . get_by_name ( "<STR_LIT>" ) ) <EOL> @ staticmethod <EOL> def _mean_elevation_at_borders ( world ) : <EOL> borders_total_elevation = <NUM_LIT:0.0> <EOL> for y in range ( world . height ) : <EOL> borders_total_elevation += world . elevation_at ( ( <NUM_LIT:0> , y ) ) <EOL> borders_total_elevation += world . elevation_at ( ( world . width - <NUM_LIT:1> , y ) ) <EOL> for x in range ( <NUM_LIT:1> , world . width - <NUM_LIT:1> ) : <EOL> borders_total_elevation += world . elevation_at ( ( x , <NUM_LIT:0> ) ) <EOL> borders_total_elevation += world . elevation_at ( ( x , world . height - <NUM_LIT:1> ) ) <EOL> n_cells_on_border = world . width * <NUM_LIT:2> + world . height * <NUM_LIT:2> - <NUM_LIT:4> <EOL> return borders_total_elevation / n_cells_on_border <EOL> def test_center_land ( self ) : <EOL> w = World . open_protobuf ( "<STR_LIT>" % self . tests_data_dir ) <EOL> el_before = TestGeneration . _mean_elevation_at_borders ( w ) <EOL> center_land ( w ) <EOL> el_after = TestGeneration . _mean_elevation_at_borders ( w ) <EOL> self . assertTrue ( el_after <= el_before ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
