Skip to content

osm2pgsql-test-style fails to load external lua style when replication tool is unavailable #2468

@JakobMiksch

Description

@JakobMiksch

related to #2464

What version of osm2pgsql are you using?

osm2pgsql version 2.1.1
Build: None
Compiled using the following library versions:
Libosmium 2.22.0
Proj 9.6.0
Lua 5.3.6

What operating system and PostgreSQL/PostGIS version are you using?

PostgreSQL 17 and PostGIS from Debian 13 stable packages

Tell us something about your system

not relevant

What did you do exactly?

  • i run standalone osm2pgsql-test-style WITHOUT osm2pgsql-replication next to it
  • my command: ./osm2pgsql-test-style trees.feature

content of trees.feature:

Feature: Test import of trees

  Scenario: An OSM tree node will be imported
    Given the OSM data
      """
      n12 Tnatural=tree,name=Old%20%Oak x34.6 y56.374
      n20 Thighway=bus_stop x34.66 y56.377
      """
    Given the style file 'trees.lua'
    When running osm2pgsql flex
    Then table trees contains exactly
      | node_id | name    |
      |      12 | Old Oak |

references style file trees.lua:

local trees = osm2pgsql.define_node_table('trees', {
    { column = 'name', type = 'text' },
    { column = 'geom', type = 'point', srid = 4326 }
})

function osm2pgsql.process_node(object)
    if object.tags.natural == 'tree' then
        trees:insert {
            name = object.tags.name,
            geom = object:as_point()
        }
    end
end

What did you expect to happen?

I expected that the tests pass.

What did happen instead?

The tests failed, because the testing itself had an error with this message:

HOOK-ERROR in before_scenario: AttributeError: 'NoneType' object has no attribute 'ReplicationServer' and no __dict__ for setting new attributes

What did you do to try analyzing the problem?

I fixed it locally by commenting these lines:

osm2pgsql_replication.ReplicationServer = None

osm2pgsql_replication.urlrequest.urlopen = _mock_urlopen

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions