Add test for example 4 from Python documentation