Skip to content

Conversation

@yohanboniface
Copy link
Member

ref: #36

Work in progress, not to be merged yet, but can be discussed at least :)

sebastic added a commit to sebastic/python-mapnik that referenced this pull request Jul 23, 2015
With Python 3 the missing parentheses are a SyntaxError.

This change along with the setup.py changes in mapnik#38 allow building the python bindings with Python 3.4 (mapnik#36)
@yohanboniface yohanboniface force-pushed the python3 branch 2 times, most recently from 6bad884 to e300078 Compare July 30, 2015 10:08
@yohanboniface
Copy link
Member Author

I've made a first shot porting tests.

All syntax and idioms should be ok. Remain 7 failures and 2 errors that require a deeper look at Mapnik internal, and I'm keeping them for a later session.

For the record, I need to manually set my fonts directory, otherwise Mapnik don't find them and I've a bunch of error due to this: set -gx MAPNIK_FONT_DIRECTORY '/usr/share/fonts/truetype/'

There is a huge PEP8 cleaning needed, but I prefer to make them in a separate commit, and when all tests passes, so it does not generate useless noise while debugging.

Current tests status

======================================================================
ERROR: python_tests.feature_test.test_add_geom_wkb
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ybon/Code/cpp/python-mapnik/.eggs/nose-1.3.7-py3.4.egg/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/ybon/Code/cpp/python-mapnik/test/python_tests/feature_test.py", line 42, in test_add_geom_wkb
    eq_(geometry.is_valid(), True)
AttributeError: 'Geometry' object has no attribute 'is_valid'

======================================================================
ERROR: python_tests.json_feature_properties_test.test_char_escaping
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ybon/Code/cpp/python-mapnik/.eggs/nose-1.3.7-py3.4.egg/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/ybon/Code/cpp/python-mapnik/test/python_tests/json_feature_properties_test.py", line 91, in test_char_escaping
    pyjson2 = json.loads(char['json'])
  File "/usr/lib/python3.4/json/__init__.py", line 318, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.4/json/decoder.py", line 343, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.4/json/decoder.py", line 359, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Invalid control character at: line 1 column 76 (char 75)

======================================================================
FAIL: python_tests.image_filters_test.test_style_level_image_filter
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ybon/Code/cpp/python-mapnik/.eggs/nose-1.3.7-py3.4.egg/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/ybon/Code/cpp/python-mapnik/test/python_tests/image_filters_test.py", line 64, in test_style_level_image_filter
    eq_(len(fails), 0, '\n'+'\n'.join(fails))
AssertionError: 
failed comparing actual (/tmp/mapnik-style-image-filter-none.png) and expected(tests/python_tests/images/style-image-filter/none.png)
failed comparing actual (/tmp/mapnik-style-image-filter-agg-stack-blur22.png) and expected(tests/python_tests/images/style-image-filter/agg-stack-blur22.png)
failed comparing actual (/tmp/mapnik-style-image-filter-blur.png) and expected(tests/python_tests/images/style-image-filter/blur.png)
failed comparing actual (/tmp/mapnik-style-image-filter-edge-detect.png) and expected(tests/python_tests/images/style-image-filter/edge-detect.png)
failed comparing actual (/tmp/mapnik-style-image-filter-emboss.png) and expected(tests/python_tests/images/style-image-filter/emboss.png)
failed comparing actual (/tmp/mapnik-style-image-filter-gray.png) and expected(tests/python_tests/images/style-image-filter/gray.png)
failed comparing actual (/tmp/mapnik-style-image-filter-invert.png) and expected(tests/python_tests/images/style-image-filter/invert.png)
failed comparing actual (/tmp/mapnik-style-image-filter-sharpen.png) and expected(tests/python_tests/images/style-image-filter/sharpen.png)
failed comparing actual (/tmp/mapnik-style-image-filter-sobel.png) and expected(tests/python_tests/images/style-image-filter/sobel.png)
failed comparing actual (/tmp/mapnik-style-image-filter-x-gradient.png) and expected(tests/python_tests/images/style-image-filter/x-gradient.png)
failed comparing actual (/tmp/mapnik-style-image-filter-y-gradient.png) and expected(tests/python_tests/images/style-image-filter/y-gradient.png)

======================================================================
FAIL: python_tests.projection_test.test_proj_antimeridian_bbox
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ybon/Code/cpp/python-mapnik/.eggs/nose-1.3.7-py3.4.egg/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/ybon/Code/cpp/python-mapnik/test/python_tests/projection_test.py", line 143, in test_proj_antimeridian_bbox
    assert_box2d_almost_equal(fwd_ext, normal)
  File "/home/ybon/Code/cpp/python-mapnik/test/python_tests/utilities.py", line 105, in assert_box2d_almost_equal
    assert_almost_equal(a.maxy, b.maxy, msg=msg)
AssertionError: -24.977464316684916 != -24.9771195151 within 7 places : Box2d(148.7667597488545,-60.1222810239604,159.95484892960656,-24.977464316684916) != Box2d(148.766759749,-60.1222810238,159.95484893,-24.9771195151)

======================================================================
FAIL: python_tests.raster_colorizer_test.test_stop_label
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ybon/Code/cpp/python-mapnik/.eggs/nose-1.3.7-py3.4.egg/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/ybon/Code/cpp/python-mapnik/test/python_tests/raster_colorizer_test.py", line 86, in test_stop_label
    assert stop.label == label, stop.label
AssertionError: 32º C

======================================================================
FAIL: python_tests.raster_symbolizer_test.test_raster_warping
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ybon/Code/cpp/python-mapnik/.eggs/nose-1.3.7-py3.4.egg/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/ybon/Code/cpp/python-mapnik/test/python_tests/raster_symbolizer_test.py", line 180, in test_raster_warping
    eq_(actual.tostring('png32'),expected.tostring('png32'), 'failed comparing actual (%s) and expected (%s)' % (actual_file,expected_file))
AssertionError: failed comparing actual (/tmp/raster_warping.png) and expected (./images/support/raster_warping.png)

======================================================================
FAIL: python_tests.raster_symbolizer_test.test_raster_warping_does_not_overclip_source
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ybon/Code/cpp/python-mapnik/.eggs/nose-1.3.7-py3.4.egg/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/ybon/Code/cpp/python-mapnik/test/python_tests/raster_symbolizer_test.py", line 213, in test_raster_warping_does_not_overclip_source
    eq_(actual.tostring('png32'),expected.tostring('png32'), 'failed comparing actual (%s) and expected (%s)' % (actual_file,expected_file))
AssertionError: failed comparing actual (/tmp/raster_warping_does_not_overclip_source.png) and expected (./images/support/raster_warping_does_not_overclip_source.png)

======================================================================
FAIL: python_tests.render_test.test_render_with_scale_factor
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ybon/Code/cpp/python-mapnik/.eggs/nose-1.3.7-py3.4.egg/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/ybon/Code/cpp/python-mapnik/test/python_tests/render_test.py", line 250, in test_render_with_scale_factor
    eq_(actual.tostring('png32'),expected.tostring('png32'), 'failed comparing actual (%s) and expected (%s)' % (actual_file,expected_file))
AssertionError: failed comparing actual (/tmp/marker-text-line-scale-factor-1.5.png) and expected (./images/support/marker-text-line-scale-factor-1.5.png)

======================================================================
FAIL: python_tests.sqlite_rtree_test.test_geometry_round_trip
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ybon/Code/cpp/python-mapnik/.eggs/nose-1.3.7-py3.4.egg/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/ybon/Code/cpp/python-mapnik/test/python_tests/sqlite_rtree_test.py", line 160, in test_geometry_round_trip
    eq_(str(geom_wkb_blob),geom.to_wkb(mapnik.wkbByteOrder.NDR))
AssertionError: "b'\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x80^\\xc0\\x00\\x00\\x00\\x00\\x00\\x00H@'" != b'\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x80^\xc0\x00\x00\x00\x00\x00\x00H@'

----------------------------------------------------------------------
Ran 499 tests in 12.354s

FAILED (failures=7, errors=2)

Feedback welcome :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How backwards compatible is this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.6+
3.3+

@yohanboniface
Copy link
Member Author

@flippmoke I've now same failures on python 3 with python3 branch, python 2 with python3 branch and python 3 with master branch, so I'll suggest going forward and merging, and then iterate again.
I'll rebase to have clearer commit.

For the record here are the remaining errors:

======================================================================
ERROR: python_tests.feature_test.test_add_geom_wkb
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ybon/.virtualenvs/p3/local/lib/python3.4/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/ybon/Code/cpp/python-mapnik/test/python_tests/feature_test.py", line 42, in test_add_geom_wkb
    eq_(geometry.is_valid(), True)
AttributeError: 'Geometry' object has no attribute 'is_valid'

======================================================================
FAIL: python_tests.image_filters_test.test_style_level_image_filter
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ybon/.virtualenvs/p3/local/lib/python3.4/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/ybon/Code/cpp/python-mapnik/test/python_tests/image_filters_test.py", line 64, in test_style_level_image_filter
    eq_(len(fails), 0, '\n'+'\n'.join(fails))
AssertionError: 
failed comparing actual (/tmp/mapnik-style-image-filter-none.png) and expected(tests/python_tests/images/style-image-filter/none.png)
failed comparing actual (/tmp/mapnik-style-image-filter-agg-stack-blur22.png) and expected(tests/python_tests/images/style-image-filter/agg-stack-blur22.png)
failed comparing actual (/tmp/mapnik-style-image-filter-blur.png) and expected(tests/python_tests/images/style-image-filter/blur.png)
failed comparing actual (/tmp/mapnik-style-image-filter-edge-detect.png) and expected(tests/python_tests/images/style-image-filter/edge-detect.png)
failed comparing actual (/tmp/mapnik-style-image-filter-emboss.png) and expected(tests/python_tests/images/style-image-filter/emboss.png)
failed comparing actual (/tmp/mapnik-style-image-filter-gray.png) and expected(tests/python_tests/images/style-image-filter/gray.png)
failed comparing actual (/tmp/mapnik-style-image-filter-invert.png) and expected(tests/python_tests/images/style-image-filter/invert.png)
failed comparing actual (/tmp/mapnik-style-image-filter-sharpen.png) and expected(tests/python_tests/images/style-image-filter/sharpen.png)
failed comparing actual (/tmp/mapnik-style-image-filter-sobel.png) and expected(tests/python_tests/images/style-image-filter/sobel.png)
failed comparing actual (/tmp/mapnik-style-image-filter-x-gradient.png) and expected(tests/python_tests/images/style-image-filter/x-gradient.png)
failed comparing actual (/tmp/mapnik-style-image-filter-y-gradient.png) and expected(tests/python_tests/images/style-image-filter/y-gradient.png)

======================================================================
FAIL: python_tests.projection_test.test_proj_antimeridian_bbox
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ybon/.virtualenvs/p3/local/lib/python3.4/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/ybon/Code/cpp/python-mapnik/test/python_tests/projection_test.py", line 147, in test_proj_antimeridian_bbox
    assert_box2d_almost_equal(fwd_ext, normal)
  File "/home/ybon/Code/cpp/python-mapnik/test/python_tests/utilities.py", line 107, in assert_box2d_almost_equal
    assert_almost_equal(a.maxy, b.maxy, msg=msg)
AssertionError: -24.977464316684916 != -24.9771195151 within 7 places : Box2d(148.7667597488545,-60.1222810239604,159.95484892960656,-24.977464316684916) != Box2d(148.766759749,-60.1222810238,159.95484893,-24.9771195151)

======================================================================
FAIL: python_tests.raster_symbolizer_test.test_raster_warping
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ybon/.virtualenvs/p3/local/lib/python3.4/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/ybon/Code/cpp/python-mapnik/test/python_tests/raster_symbolizer_test.py", line 180, in test_raster_warping
    eq_(actual.tostring('png32'),expected.tostring('png32'), 'failed comparing actual (%s) and expected (%s)' % (actual_file,expected_file))
AssertionError: failed comparing actual (/tmp/raster_warping.png) and expected (./images/support/raster_warping.png)

======================================================================
FAIL: python_tests.raster_symbolizer_test.test_raster_warping_does_not_overclip_source
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ybon/.virtualenvs/p3/local/lib/python3.4/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/ybon/Code/cpp/python-mapnik/test/python_tests/raster_symbolizer_test.py", line 213, in test_raster_warping_does_not_overclip_source
    eq_(actual.tostring('png32'),expected.tostring('png32'), 'failed comparing actual (%s) and expected (%s)' % (actual_file,expected_file))
AssertionError: failed comparing actual (/tmp/raster_warping_does_not_overclip_source.png) and expected (./images/support/raster_warping_does_not_overclip_source.png)

======================================================================
FAIL: python_tests.render_test.test_render_with_scale_factor
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ybon/.virtualenvs/p3/local/lib/python3.4/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/ybon/Code/cpp/python-mapnik/test/python_tests/render_test.py", line 248, in test_render_with_scale_factor
    eq_(actual.tostring('png32'),expected.tostring('png32'), 'failed comparing actual (%s) and expected (%s)' % (actual_file,expected_file))
AssertionError: failed comparing actual (/tmp/marker-text-line-scale-factor-1.5.png) and expected (./images/support/marker-text-line-scale-factor-1.5.png)

----------------------------------------------------------------------
Ran 500 tests in 15.712s

FAILED (errors=1, failures=5)

Plus, in the three cases, I've 108 errors on the visual suite.

@yohanboniface yohanboniface force-pushed the python3 branch 3 times, most recently from 847951e to 72dcb2f Compare August 3, 2015 15:58
flippmoke added a commit that referenced this pull request Aug 4, 2015
@flippmoke flippmoke merged commit 06ea926 into mapnik:master Aug 4, 2015
@yohanboniface
Copy link
Member Author

\o/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants