@lonvia commented on this pull request.


> @@ -541,6 +564,21 @@ def check_program_output(context, kind):
         assert line in s,\
                f"Output '{line}' not found in {kind} output:\n{s}\n"
 
+@then(r"the (?P<kind>\w+) output matches contents of (?P<result_file>.*)")
+def check_program_output_against_file(context, kind, result_file):
+    if kind == 'error':
+        s = context.osm2pgsql_outdata[1]
+    elif kind == 'standard':
+        s = context.osm2pgsql_outdata[0]
+    else:
+        assert not "Expect one of error, standard"
+
+    test_dir = (context.user_args.test_data_dir or Path('.')).resolve()
+    expected = open(test_dir / result_file, 'r').read()

Please use with here to close the file properly:

```
with open(...) as fd:
    expected = fd.read()
```

> @@ -541,6 +564,21 @@ def check_program_output(context, kind):
         assert line in s,\
                f"Output '{line}' not found in {kind} output:\n{s}\n"
 
+@then(r"the (?P<kind>\w+) output matches contents of (?P<result_file>.*)")
+def check_program_output_against_file(context, kind, result_file):
+    if kind == 'error':
+        s = context.osm2pgsql_outdata[1]
+    elif kind == 'standard':
+        s = context.osm2pgsql_outdata[0]
+    else:
+        assert not "Expect one of error, standard"
+
+    test_dir = (context.user_args.test_data_dir or Path('.')).resolve()
+    expected = open(test_dir / result_file, 'r').read()
+
+    assert s == expected, \
+           f"Output '{s}' does not match contents of {result_file}\n"

{s} will be a multiline string here, better put it at the end: `Output does not 
match contents of {result_file}. Actual output: \n{s}`

-- 
Reply to this email directly or view it on GitHub:
https://github.com/osm2pgsql-dev/osm2pgsql/pull/2453#pullrequestreview-3764622873
You are receiving this because you are subscribed to this thread.

Message ID: <osm2pgsql-dev/osm2pgsql/pull/2453/review/[email protected]>
_______________________________________________
Tile-serving mailing list
[email protected]
https://lists.openstreetmap.org/listinfo/tile-serving

Reply via email to