Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mapscript/python/pymodule.i
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ CreateTupleFromDoubleArray( double *first, unsigned int size ) {
const char* val = msLookupHashTable(hashTable, key);
if( val )
{
#if PY_VERSION_HEX >= 0x03000000
%#if PY_VERSION_HEX >= 0x03000000
PyObject *py_key = PyUnicode_FromString(key);
PyObject *py_val = PyUnicode_FromString(val);
#else
%#else
PyObject *py_key = PyString_FromString(key);
PyObject *py_val = PyString_FromString(val);
#endif
%#endif

PyDict_SetItem($result, py_key, py_val );
Py_DECREF(py_key);
Expand Down
2 changes: 1 addition & 1 deletion mapscript/python/tests/cases/classtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import unittest

# the testing module helps us import the pre-installed mapscript
from testing import mapscript, MapTestCase
from .testing import mapscript, MapTestCase

# ===========================================================================
# Test begins now
Expand Down
7 changes: 3 additions & 4 deletions mapscript/python/tests/cases/clonetest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@

# the testing module helps us import the pre-installed mapscript

from testing import mapscript
from testing import TESTMAPFILE
from testing import MapscriptTestCase
from .testing import mapscript
from .testing import TESTMAPFILE

# ===========================================================================
# Base class

class MapCloneTestCase(MapscriptTestCase):
class MapCloneTestCase(unittest.TestCase):
"""Base class for testing with a map fixture"""

def setUp(self):
Expand Down
3 changes: 1 addition & 2 deletions mapscript/python/tests/cases/colortest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
import unittest

# the testing module helps us import the pre-installed mapscript
from testing import mapscript
from testing import MapPrimitivesTestCase
from .testing import MapPrimitivesTestCase, mapscript

# ===========================================================================
# Test begins now
Expand Down
2 changes: 1 addition & 1 deletion mapscript/python/tests/cases/fonttest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import unittest

# the testing module helps us import the pre-installed mapscript
from testing import mapscript, TESTMAPFILE, TESTS_PATH
from .testing import mapscript, TESTMAPFILE, TESTS_PATH


class FontTestCase(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion mapscript/python/tests/cases/hashtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import unittest

# the testing module helps us import the pre-installed mapscript
from testing import mapscript, MapTestCase
from .testing import mapscript, MapTestCase

# ===========================================================================
# Base class for hashtable tests. Derived classes use these tests, but
Expand Down
41 changes: 17 additions & 24 deletions mapscript/python/tests/cases/imagetest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,11 @@

import os, sys
import unittest

from io import BytesIO
# the testing module helps us import the pre-installed mapscript

from testing import mapscript
from testing import TEST_IMAGE as test_image
from testing import TESTMAPFILE
from testing import MapTestCase
from StringIO import StringIO
import cStringIO
from .testing import TESTMAPFILE, TEST_IMAGE as test_image, mapscript
from .testing import MapTestCase
import urllib


Expand Down Expand Up @@ -115,12 +111,11 @@ def xtestConstructorStream(self):
assert imgobj.height == 200
assert imgobj.width == 200

def xtestConstructorStringIO(self):
"""imageObj with a cStringIO works"""
f = open(test_image, 'rb')
data = f.read()
f.close()
s = cStringIO.StringIO(data)
def xtestConstructorBytesIO(self):
"""imageObj with a BytesIO works"""
with open(test_image, 'rb') as f:
data = f.read()
s = BytesIO(data)
imgobj = mapscript.imageObj(s)
assert imgobj.thisown == 1
assert imgobj.height == 200
Expand Down Expand Up @@ -153,18 +148,17 @@ def testImageWrite(self):
else:
assert 1

def testImageWriteStringIO(self):
"""image writes data to a StringIO instance"""
def testImageWriteBytesIO(self):
"""image writes data to a BytesIO instance"""
image = self.map.draw()
assert image.thisown == 1

s = cStringIO.StringIO()
s = BytesIO()
image.write(s)

filename = 'testImageWriteStringIO.png'
fh = open(filename, 'wb')
fh.write(s.getvalue())
fh.close()
filename = 'testImageWriteBytesIO.png'
with open(filename, 'wb') as fh:
fh.write(s.getvalue())
if have_image:
pyimg = Image.open(filename)
assert pyimg.format == 'PNG'
Expand All @@ -178,12 +172,11 @@ def testImageGetBytes(self):
image = self.map.draw()
assert image.thisown == 1

s = cStringIO.StringIO(image.getBytes())
s = BytesIO(image.getBytes())

filename = 'testImageGetBytes.png'
fh = open(filename, 'wb')
fh.write(s.getvalue())
fh.close()
with open(filename, 'wb') as fh:
fh.write(s.getvalue())
if have_image:
pyimg = Image.open(filename)
assert pyimg.format == 'PNG'
Expand Down
2 changes: 1 addition & 1 deletion mapscript/python/tests/cases/labeltest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import unittest

# the testing module helps us import the pre-installed mapscript
from testing import mapscript, MapTestCase
from .testing import mapscript, MapTestCase

# ===========================================================================
# Test begins now
Expand Down
4 changes: 2 additions & 2 deletions mapscript/python/tests/cases/layertest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
import unittest

# the testing module helps us import the pre-installed mapscript
from testing import mapscript
from testing import MapTestCase
from .testing import mapscript
from .testing import MapTestCase

# Base class
class MapLayerTestCase(MapTestCase):
Expand Down
3 changes: 1 addition & 2 deletions mapscript/python/tests/cases/linetest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
import unittest

# the testing module helps us import the pre-installed mapscript
from testing import mapscript
from testing import MapPrimitivesTestCase
from .testing import MapPrimitivesTestCase, mapscript

class LineObjTestCase(MapPrimitivesTestCase):
"""Testing the lineObj class in stand-alone mode"""
Expand Down
10 changes: 5 additions & 5 deletions mapscript/python/tests/cases/maptest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import unittest

# the testing module helps us import the pre-installed mapscript
from testing import mapscript, MapTestCase, TESTMAPFILE
from .testing import mapscript, MapTestCase, TESTMAPFILE

# ===========================================================================
# Test begins now
Expand Down Expand Up @@ -96,9 +96,9 @@ def testMapInsertLayer(self):
n = self.map.numlayers
layer = mapscript.layerObj()
layer.name = 'new'
assert layer.map == None, layer.map
assert layer.map == None, layer.map
index = self.map.insertLayer(layer)
assert layer.map != None, layer.map
assert layer.map != None, layer.map
assert index == n, index
assert self.map.numlayers == n + 1
names = [self.map.getLayer(i).name for i in range(self.map.numlayers)]
Expand All @@ -112,9 +112,9 @@ def testMapInsertLayerAtZero(self):
n = self.map.numlayers
layer = mapscript.layerObj()
layer.name = 'new'
assert layer.map == None, layer.map
assert layer.map == None, layer.map
index = self.map.insertLayer(layer, 0)
assert layer.map != None, layer.map
assert layer.map != None, layer.map
assert index == 0, index
assert self.map.numlayers == n + 1
names = [self.map.getLayer(i).name for i in range(self.map.numlayers)]
Expand Down
3 changes: 1 addition & 2 deletions mapscript/python/tests/cases/outputformattest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
import unittest

# the testing module helps us import the pre-installed mapscript
from testing import mapscript
from testing import MapTestCase
from .testing import MapTestCase, mapscript

# ===========================================================================
# Test begins now
Expand Down
3 changes: 1 addition & 2 deletions mapscript/python/tests/cases/owstest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
import unittest

# the testing module helps us import the pre-installed mapscript
from testing import mapscript
from testing import MapTestCase
from .testing import MapTestCase, mapscript

# ===========================================================================
# Test begins now
Expand Down
2 changes: 1 addition & 1 deletion mapscript/python/tests/cases/parentreference.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import unittest

# the testing module helps us import the pre-installed mapscript
from testing import mapscript, MapTestCase, TESTMAPFILE
from .testing import mapscript, MapTestCase, TESTMAPFILE

# ===========================================================================
# Test begins now
Expand Down
3 changes: 1 addition & 2 deletions mapscript/python/tests/cases/pgtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
import unittest

# the testing module helps us import the pre-installed mapscript
from testing import mapscript
from testing import MapTestCase
from .testing import MapTestCase, mapscript

PG_CONNECTION_STRING="dbname=mapserver_test user=postgres"

Expand Down
5 changes: 2 additions & 3 deletions mapscript/python/tests/cases/pointtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@
import unittest

# the testing module helps us import the pre-installed mapscript
from testing import mapscript
from testing import MapscriptTestCase
from .testing import mapscript

class PointObjTestCase(MapscriptTestCase):
class PointObjTestCase(unittest.TestCase):

def testPointObjConstructorNoArgs(self):
"""point can be created with no arguments"""
Expand Down
6 changes: 3 additions & 3 deletions mapscript/python/tests/cases/recttest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
import unittest

# the testing module helps us import the pre-installed mapscript
from testing import mapscript
from testing import MapPrimitivesTestCase
from .testing import mapscript
from .testing import MapPrimitivesTestCase

# ===========================================================================
# Test begins now
Expand Down Expand Up @@ -85,7 +85,7 @@ def testExceptionMessage(self):
"""test formatted error message"""
try:
r = mapscript.rectObj(1.0, -2.0, -3.0, 4.0)
except mapscript.MapServerError, msg:
except mapscript.MapServerError as msg:
assert str(msg) == "rectObj(): Invalid rectangle. { 'minx': 1.000000 , 'miny': -2.000000 , 'maxx': -3.000000 , 'maxy': 4.000000 }", msg

def testRect__str__(self):
Expand Down
2 changes: 1 addition & 1 deletion mapscript/python/tests/cases/refcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import unittest

# the testing module helps us import the pre-installed mapscript
from testing import mapscript, MapTestCase, TESTMAPFILE
from .testing import mapscript, MapTestCase, TESTMAPFILE

# ===========================================================================
# Test begins now
Expand Down
3 changes: 1 addition & 2 deletions mapscript/python/tests/cases/resultcachetest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
import unittest

# the testing module helps us import the pre-installed mapscript
from testing import mapscript
from testing import MapTestCase, MapPrimitivesTestCase
from .testing import MapTestCase, MapPrimitivesTestCase, mapscript

# Base class
class LayerQueryTestCase(MapTestCase):
Expand Down
2 changes: 1 addition & 1 deletion mapscript/python/tests/cases/shapefiletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import os

# the testing module helps us import the pre-installed mapscript
from testing import mapscript, TESTS_PATH
from .testing import mapscript, TESTS_PATH

class AddShapeTestCase(unittest.TestCase):

Expand Down
5 changes: 2 additions & 3 deletions mapscript/python/tests/cases/shapetest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@
import unittest

# the testing module helps us import the pre-installed mapscript
from testing import mapscript, MapTestCase
from testing import MapPrimitivesTestCase, ShapeObjTestCase
from testing import MapscriptTestCase
from .testing import mapscript, MapTestCase
from .testing import MapPrimitivesTestCase, ShapeObjTestCase

class ShapePointTestCase(ShapeObjTestCase):
"""Test point type shapeObj in stand-alone mode"""
Expand Down
2 changes: 1 addition & 1 deletion mapscript/python/tests/cases/styletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import unittest

# the testing module helps us import the pre-installed mapscript
from testing import mapscript, MapTestCase
from .testing import mapscript, MapTestCase

class DrawProgrammedStylesTestCase(MapTestCase):
def testDrawPoints(self):
Expand Down
2 changes: 1 addition & 1 deletion mapscript/python/tests/cases/symbolsettest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import unittest

# the testing module helps us import the pre-installed mapscript
from testing import mapscript, MapTestCase, TESTMAPFILE, XMARKS_IMAGE, TESTS_PATH
from .testing import mapscript, MapTestCase, TESTMAPFILE, XMARKS_IMAGE, TESTS_PATH

SYMBOLSET = os.path.join(TESTS_PATH, "symbols.txt")

Expand Down
16 changes: 7 additions & 9 deletions mapscript/python/tests/cases/symboltest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@

import os, sys
import unittest
import StringIO
from io import BytesIO

# the testing module helps us import the pre-installed mapscript
from testing import mapscript, MapTestCase
from testing import TESTMAPFILE, XMARKS_IMAGE, HOME_IMAGE
from .testing import mapscript, MapTestCase
from .testing import TESTMAPFILE, XMARKS_IMAGE, HOME_IMAGE

# ===========================================================================
# Test begins now
Expand All @@ -65,16 +65,14 @@ class DynamicGraphicSymbolTestCase():

def setUp(self):
MapTestCase.setUp(self)
f = open(HOME_IMAGE, 'rb')
s = StringIO.StringIO(f.read())
f.close()
with open(HOME_IMAGE, 'rb') as fh:
s = BytesIO(fh.read())
symb_img = mapscript.imageObj(s)
self.h_symbol = mapscript.symbolObj('house')
self.h_symbol.type = mapscript.MS_SYMBOL_PIXMAP
self.h_symbol.setImage(symb_img)
f = open(XMARKS_IMAGE, 'rb')
s = StringIO.StringIO(f.read())
f.close()
with open(XMARKS_IMAGE, 'rb') as fh:
s = BytesIO(fh.read())
symb_img = mapscript.imageObj(s)
self.x_symbol = mapscript.symbolObj('xmarks')
self.x_symbol.type = mapscript.MS_SYMBOL_PIXMAP
Expand Down
Loading