<s> from . import unittest <EOL> from shapely . geometry import Point , LineString , Polygon , MultiLineString , GeometryCollection <EOL> from shapely . geos import geos_version <EOL> from shapely . ops import shared_paths <EOL> @ unittest . skipIf ( geos_version < ( <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:0> ) , '<STR_LIT>' ) <EOL> class SharedPaths ( unittest . TestCase ) : <EOL> def test_shared_paths_forward ( self ) : <EOL> g1 = LineString ( [ ( <NUM_LIT:0> , <NUM_LIT:0> ) , ( <NUM_LIT:10> , <NUM_LIT:0> ) , ( <NUM_LIT:10> , <NUM_LIT:5> ) , ( <NUM_LIT:20> , <NUM_LIT:5> ) ] ) <EOL> g2 = LineString ( [ ( <NUM_LIT:5> , <NUM_LIT:0> ) , ( <NUM_LIT:15> , <NUM_LIT:0> ) ] ) <EOL> result = shared_paths ( g1 , g2 ) <EOL> self . assertTrue ( isinstance ( result , GeometryCollection ) ) <EOL> self . assertTrue ( len ( result ) == <NUM_LIT:2> ) <EOL> a , b = result <EOL> self . assertTrue ( isinstance ( a , MultiLineString ) ) <EOL> self . assertTrue ( len ( a ) == <NUM_LIT:1> ) <EOL> self . assertEqual ( a [ <NUM_LIT:0> ] . coords [ : ] , [ ( <NUM_LIT:5> , <NUM_LIT:0> ) , ( <NUM_LIT:10> , <NUM_LIT:0> ) ] ) <EOL> self . assertTrue ( b . is_empty ) <EOL> def test_shared_paths_forward ( self ) : <EOL> g1 = LineString ( [ ( <NUM_LIT:0> , <NUM_LIT:0> ) , ( <NUM_LIT:10> , <NUM_LIT:0> ) , ( <NUM_LIT:10> , <NUM_LIT:5> ) , ( <NUM_LIT:20> , <NUM_LIT:5> ) ] ) <EOL> g2 = LineString ( [ ( <NUM_LIT:15> , <NUM_LIT:0> ) , ( <NUM_LIT:5> , <NUM_LIT:0> ) ] ) <EOL> result = shared_paths ( g1 , g2 ) <EOL> self . assertTrue ( isinstance ( result , GeometryCollection ) ) <EOL> self . assertTrue ( len ( result ) == <NUM_LIT:2> ) <EOL> a , b = result <EOL> self . assertTrue ( isinstance ( b , MultiLineString ) ) <EOL> self . assertTrue ( len ( b ) == <NUM_LIT:1> ) <EOL> self . assertEqual ( b [ <NUM_LIT:0> ] . coords [ : ] , [ ( <NUM_LIT:5> , <NUM_LIT:0> ) , ( <NUM_LIT:10> , <NUM_LIT:0> ) ] ) <EOL> self . assertTrue ( a . is_empty ) <EOL> def test_wrong_type ( self ) : <EOL> g1 = Point ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> g2 = LineString ( [ ( <NUM_LIT:5> , <NUM_LIT:0> ) , ( <NUM_LIT:15> , <NUM_LIT:0> ) ] ) <EOL> with self . assertRaises ( TypeError ) : <EOL> result = shared_paths ( g1 , g2 ) <EOL> with self . assertRaises ( TypeError ) : <EOL> result = shared_paths ( g2 , g1 ) <EOL> def test_suite ( ) : <EOL> return unittest . TestLoader ( ) . loadTestsFromTestCase ( SharedPaths ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
