#188 Fix sqlite3 deterministic test
Merged 3 years ago by churchyard. Opened 3 years ago by churchyard.
rpms/ churchyard/python3 f32-sqlitetest  into  f32

Fix sqlite3 deterministic test
Victor Stinner • 3 years ago  
@@ -0,0 +1,76 @@ 

+ commit 00a240bf7f95bbd220f1cfbf9eb58484a5f9681a

+ Author: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>

+ Date:   Fri May 29 05:46:34 2020 -0700

+ 

+     bpo-40784: Fix sqlite3 deterministic test (GH-20448)

+     

+     (cherry picked from commit c610d970f5373b143bf5f5900d4645e6a90fb460)

+     

+     Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>

+ 

+ diff --git a/Lib/sqlite3/test/userfunctions.py b/Lib/sqlite3/test/userfunctions.py

+ index 9501f53..c11c82e 100644

+ --- a/Lib/sqlite3/test/userfunctions.py

+ +++ b/Lib/sqlite3/test/userfunctions.py

+ @@ -1,8 +1,7 @@

+ -#-*- coding: iso-8859-1 -*-

+  # pysqlite2/test/userfunctions.py: tests for user-defined functions and

+  #                                  aggregates.

+  #

+ -# Copyright (C) 2005-2007 Gerhard H�ring <gh@ghaering.de>

+ +# Copyright (C) 2005-2007 Gerhard Häring <gh@ghaering.de>

+  #

+  # This file is part of pysqlite.

+  #

+ @@ -158,6 +157,7 @@ class FunctionTests(unittest.TestCase):

+          self.con.create_function("isblob", 1, func_isblob)

+          self.con.create_function("islonglong", 1, func_islonglong)

+          self.con.create_function("spam", -1, func)

+ +        self.con.execute("create table test(t text)")

+  

+      def tearDown(self):

+          self.con.close()

+ @@ -276,18 +276,36 @@ class FunctionTests(unittest.TestCase):

+          val = cur.fetchone()[0]

+          self.assertEqual(val, 2)

+  

+ +    # Regarding deterministic functions:

+ +    #

+ +    # Between 3.8.3 and 3.15.0, deterministic functions were only used to

+ +    # optimize inner loops, so for those versions we can only test if the

+ +    # sqlite machinery has factored out a call or not. From 3.15.0 and onward,

+ +    # deterministic functions were permitted in WHERE clauses of partial

+ +    # indices, which allows testing based on syntax, iso. the query optimizer.

+ +    @unittest.skipIf(sqlite.sqlite_version_info < (3, 8, 3), "Requires SQLite 3.8.3 or higher")

+      def CheckFuncNonDeterministic(self):

+          mock = unittest.mock.Mock(return_value=None)

+ -        self.con.create_function("deterministic", 0, mock, deterministic=False)

+ -        self.con.execute("select deterministic() = deterministic()")

+ -        self.assertEqual(mock.call_count, 2)

+ -

+ -    @unittest.skipIf(sqlite.sqlite_version_info < (3, 8, 3), "deterministic parameter not supported")

+ +        self.con.create_function("nondeterministic", 0, mock, deterministic=False)

+ +        if sqlite.sqlite_version_info < (3, 15, 0):

+ +            self.con.execute("select nondeterministic() = nondeterministic()")

+ +            self.assertEqual(mock.call_count, 2)

+ +        else:

+ +            with self.assertRaises(sqlite.OperationalError):

+ +                self.con.execute("create index t on test(t) where nondeterministic() is not null")

+ +

+ +    @unittest.skipIf(sqlite.sqlite_version_info < (3, 8, 3), "Requires SQLite 3.8.3 or higher")

+      def CheckFuncDeterministic(self):

+          mock = unittest.mock.Mock(return_value=None)

+          self.con.create_function("deterministic", 0, mock, deterministic=True)

+ -        self.con.execute("select deterministic() = deterministic()")

+ -        self.assertEqual(mock.call_count, 1)

+ +        if sqlite.sqlite_version_info < (3, 15, 0):

+ +            self.con.execute("select deterministic() = deterministic()")

+ +            self.assertEqual(mock.call_count, 1)

+ +        else:

+ +            try:

+ +                self.con.execute("create index t on test(t) where deterministic() is not null")

+ +            except sqlite.OperationalError:

+ +                self.fail("Unexpected failure while creating partial index")

+  

+      @unittest.skipIf(sqlite.sqlite_version_info >= (3, 8, 3), "SQLite < 3.8.3 needed")

+      def CheckFuncDeterministicNotSupported(self):

file modified
+11 -1
@@ -17,7 +17,7 @@ 

  #global prerel ...

  %global upstream_version %{general_version}%{?prerel}

  Version: %{general_version}%{?prerel:~%{prerel}}

- Release: 1%{?dist}

+ Release: 2%{?dist}

  License: Python

  

  
@@ -271,6 +271,12 @@ 

  # Ideally, we should talk to upstream and explain why we don't want this

  Patch328: 00328-pyc-timestamp-invalidation-mode.patch

  

+ # 00350 #

+ # bpo-40784: Fix sqlite3 deterministic test (GH-20448)

+ # https://bugs.python.org/issue40784

+ # https://github.com/python/cpython/commit/00a240bf7f95bbd220f1cfbf9eb58484a5f9681a

+ Patch350: 00350-sqlite-fix-deterministic-test.patch

+ 

  # (New patches go here ^^^)

  #

  # When adding new patches to "python" and "python3" in Fedora, EL, etc.,
@@ -618,6 +624,7 @@ 

  %patch251 -p1

  %patch274 -p1

  %patch328 -p1

+ %patch350 -p1

  

  

  # Remove files that should be generated by the build
@@ -1561,6 +1568,9 @@ 

  # ======================================================

  

  %changelog

+ * Fri May 29 2020 Victor Stinner <vstinner@python.org> - 3.8.3-2

+ - Fix sqlite3 deterministic test

+ 

  * Fri May 15 2020 Miro Hrončok <mhroncok@redhat.com> - 3.8.3-1

  - Rebased to 3.8.3 final

  

Build failed.

rebased onto ff5cdbc

3 years ago

Build succeeded.

I've discovered a Pagure bug when using ferrypick to backport this from rawhide: https://pagure.io/pagure/issue/4901 -- hence the first CI failure. I've corrected the patch content to fix the problem here.

LGTM. I didn't check the exact encoding of the author name in the patch :-)

+ -#-*- coding: iso-8859-1 -*-
(...)
+ -# Copyright (C) 2005-2007 Gerhard H�ring <gh@ghaering.de>
+ +# Copyright (C) 2005-2007 Gerhard Häring <gh@ghaering.de>

Pull-Request has been merged by churchyard

3 years ago