File rasterio-1.3.9-Build-two-branches-master-and-the-.patch of Package python-rasterio

From 121335576a5ee5fc739d7b315498cc4a77ac6eb8 Mon Sep 17 00:00:00 2001
From: Sean Gillies <sean.gillies@gmail.com>
Date: Fri, 3 Nov 2023 15:02:10 -0600
Subject: [PATCH] Build two branches, master and the latest release branch
 (#2959)

* Build two branches, master and the latest release branch

* Make comparisons more robust against 3.7/3.8 differences

* In a merge test, compare ascii grid data as single strings

Resolves #2958

* Run builds against latest GDAL weekly

---------

Co-authored-by: Sean Gillies <seangillies@Seans-MacBook-Air.local>
---
 .github/workflows/test_gdal_latest.yaml | 10 ++++---
 CHANGES.txt                             |  8 ++++++
 ci/gdal-compile.sh                      |  2 +-
 tests/test_read_resample.py             |  2 +-
 tests/test_rio_merge.py                 | 36 +++++++++++++++++--------
 5 files changed, 41 insertions(+), 17 deletions(-)

--- a/.github/workflows/test_gdal_latest.yaml
+++ b/.github/workflows/test_gdal_latest.yaml
@@ -1,10 +1,8 @@
 name: Test GDAL Latest
 
 on:
-  push:
-    branches: [ main, 'maint-*' ]
   schedule:
-    - cron:  '0 0 * * 0'
+    - cron:  '0 2 * * 1'
   pull_request:  # also build on PRs touching this file
     paths:
       - ".github/workflows/test_gdal_latest.yaml"
@@ -23,6 +21,10 @@ jobs:
       GDAL_DIR: ${{ github.workspace }}/gdal_install
       GDAL_DATA: ${{ github.workspace }}/gdal_install/share/gdal
       LD_LIBRARY_PATH: "${{ github.workspace }}/gdal_install/lib/:${LD_LIBRARY_PATH}"
+    strategy:
+      fail-fast: false
+      matrix:
+        gdal-branch: ['master', 'release/3.7']
     steps:
       - uses: actions/checkout@v3
       - name: Update
@@ -63,7 +65,7 @@ jobs:
             cmake \
             curl \
             git
-          bash ci/gdal-compile.sh git
+          bash ci/gdal-compile.sh git ${{ matrix.gdal-branch }}
 
       - name: Install dependencies
         run: |
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,6 +1,14 @@
 Changes
 =======
 
+Next (TBD)
+----------
+
+Bug fixes:
+
+- Adjust several tests to small differences in output between GDAL 3.7 and 3.8
+  (#2959).
+
 1.3.9 (2023-10-18)
 ------------------
 
--- a/ci/gdal-compile.sh
+++ b/ci/gdal-compile.sh
@@ -7,7 +7,7 @@ echo "Building GDAL ($1) from source..."
 BUILD_GDAL_DIR=gdal-${1:0:5}
 # Download PROJ
 if [[ $1 == "git" ]]; then
-  git clone https://github.com/OSGeo/GDAL.git ${BUILD_GDAL_DIR}
+  git clone https://github.com/OSGeo/GDAL.git --branch $2 ${BUILD_GDAL_DIR}
 else
   curl https://download.osgeo.org/gdal/${1:0:5}/gdal-$1.tar.gz > ${BUILD_GDAL_DIR}.tar.gz
   tar zxf ${BUILD_GDAL_DIR}.tar.gz
--- a/tests/test_read_resample.py
+++ b/tests/test_read_resample.py
@@ -103,4 +103,4 @@ def test_resampling_rms():
         expected = np.array([
             [1.35266399, 0.95388681],
             [0.29308701, 1.54074657]], dtype=np.float32)
-        assert (rms == expected).all()  # all True.
+        assert np.allclose(rms, expected)
--- a/tests/test_rio_merge.py
+++ b/tests/test_rio_merge.py
@@ -1,6 +1,6 @@
 """Unittests for $ rio merge"""
 
-
+from io import StringIO
 import os
 import sys
 import textwrap
@@ -521,15 +521,17 @@ def test_merge_precision(tmpdir, precisi
         xllcorner    0.000000000000
         yllcorner    0.000000000000
         cellsize     1.000000000000
-         1 2 3 4 1 2 3 4
-         3 4 5 6 3 4 5 6
-         4 5 6 8 4 5 6 8
-         7 9 5 4 7 9 5 4
-         1 2 3 4 1 2 3 4
-         3 4 5 6 3 4 5 6
-         4 5 6 8 4 5 6 8
-         7 9 5 4 7 9 5 4
-         """
+        1 2 3 4 1 2 3 4
+        3 4 5 6 3 4 5 6
+        4 5 6 8 4 5 6 8
+        7 9 5 4 7 9 5 4
+        1 2 3 4 1 2 3 4
+        3 4 5 6 3 4 5 6
+        4 5 6 8 4 5 6 8
+        7 9 5 4 7 9 5 4
+        """
+
+    expected_file = StringIO(textwrap.dedent(expected))
 
     template = """\
         ncols 4
@@ -556,7 +558,19 @@ def test_merge_precision(tmpdir, precisi
     runner = CliRunner()
     result = runner.invoke(main_group, ["merge", "-f", "AAIGrid"] + precision + inputs + [outputname])
     assert result.exit_code == 0
-    assert open(outputname).read() == textwrap.dedent(expected)
+
+    # The arrangement of whitespace in the data part of the file
+    # changed between 3.7 and 3.8 to better conform. We will compare
+    # in a way that is more independent.
+    with open(outputname) as out_file:
+        # Compare header lines.
+        for i in range(5):
+            assert out_file.readline().strip() == expected_file.readline().strip()
+        
+        # Compare raster data as single strings.
+        out_data = " ".join(line.strip() for line in out_file.readlines())
+        expected_data = " ".join(line.strip() for line in expected_file.readlines())
+        assert out_data == expected_data
 
 
 @fixture(scope='function')
openSUSE Build Service is sponsored by