~ubuntu-branches/ubuntu/trusty/mapnik/trusty-proposed

« back to all changes in this revision

Viewing changes to tests/python_tests/load_map_test.py

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Sauthier
  • Date: 2009-08-27 00:28:37 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090827002837-ztqzfg2rmclfh4i9
Tags: 0.6.1-0ubuntu1
* New upstream release.
* Change usr/lib to usr/lib* to enable build on 64 bits systems due to new
  configuration in SConstruct in :
  - debian/libmapnik-dev.install
  - debian/libmapnik0.6.install
  - debian/mapnik-plugin-base

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
from nose.tools import *
 
4
from utilities import execution_path
 
5
 
 
6
import os, sys, glob, mapnik
 
7
 
 
8
def setup():
 
9
    # All of the paths used are relative, if we run the tests
 
10
    # from another directory we need to chdir()
 
11
    os.chdir(execution_path('.'))
 
12
 
 
13
# We expect these files to not raise any
 
14
# exceptions at all
 
15
def assert_loads_successfully(file):
 
16
    m = mapnik.Map(512, 512)
 
17
 
 
18
    strict = True
 
19
    mapnik.load_map(m, file, strict)
 
20
 
 
21
# We expect these files to raise a UserWarning
 
22
# and fail if there isn't one (or a different type
 
23
# of exception)
 
24
@raises(UserWarning)
 
25
def assert_raises_userwarning(file):
 
26
    m = mapnik.Map(512, 512)
 
27
 
 
28
    strict = True
 
29
    mapnik.load_map(m, file, strict)
 
30
 
 
31
def test_broken_files():
 
32
    broken_files = glob.glob("../data/broken_maps/*.xml")
 
33
 
 
34
    # Add a filename that doesn't exist 
 
35
    broken_files.append("../data/broken/does_not_exist.xml")
 
36
 
 
37
    for file in broken_files:
 
38
        yield assert_raises_userwarning, file
 
39
 
 
40
def test_good_files():
 
41
    good_files = glob.glob("../data/good_maps/*.xml")
 
42
 
 
43
    for file in good_files:
 
44
        yield assert_loads_successfully, file