def test_encode(self):
        """
        Ensure objects that implement __geo_interface__ can be encoded into
        GeoJSON strings
        """
        actual = geojson.dumps(self.restaurant1, sort_keys=True)
        self.assertEqual(actual, self.restaurant_str)

        actual = geojson.dumps(self.restaurant2, sort_keys=True)
        self.assertEqual(actual, self.restaurant_str)

        # Classes that don't implement geo interface should raise TypeError
        with self.assertRaises(TypeError):
            geojson.dumps(self.restaurant_nogeo)

        Ensure objects that implement __geo_interface__ can be encoded into
        GeoJSON strings
        
tests/test_geo_interface.py