File: test_integration.py

package info (click to toggle)
fiona 1.10.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,632 kB
  • sloc: python: 12,616; makefile: 214; sh: 45
file content (42 lines) | stat: -rw-r--r-- 1,148 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""Unittests to verify Fiona is functioning properly with other software."""


from collections import UserDict

import fiona
from fiona.model import Feature


def test_dict_subclass(tmpdir):
    """Rasterio now has a `CRS()` class that subclasses
    `collections.UserDict()`.  Make sure we can receive it.

    `UserDict()` is a good class to test against because in Python 2 it is
    not a subclass of `collections.Mapping()`, so it provides an edge case.
    """

    class CRS(UserDict):
        pass

    outfile = str(tmpdir.join("test_UserDict.geojson"))

    profile = {
        "crs": CRS(init="EPSG:4326"),
        "driver": "GeoJSON",
        "schema": {"geometry": "Point", "properties": {}},
    }

    with fiona.open(outfile, "w", **profile) as dst:
        dst.write(
            Feature.from_dict(
                **{
                    "type": "Feature",
                    "properties": {},
                    "geometry": {"type": "Point", "coordinates": (10, -10)},
                }
            )
        )

    with fiona.open(outfile) as src:
        assert len(src) == 1
        assert src.crs == {"init": "epsg:4326"}