File use-sys-executable-for-tests.patch of Package python-Flask-Migrate

From d324b3e12448214eecfa335e344e0cfd3420dce7 Mon Sep 17 00:00:00 2001
From: John Vandenberg <jayvdb@gmail.com>
Date: Sat, 14 Sep 2019 18:40:50 +0700
Subject: [PATCH] tests: Use sys.executable

Also re-order imports.

Closes https://github.com/miguelgrinberg/Flask-Migrate/issues/289
---
 tests/test_migrate.py         | 25 +++++++++++++------------
 tests/test_multidb_migrate.py | 15 ++++++++-------
 2 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/tests/test_migrate.py b/tests/test_migrate.py
index 85548d1..e802fd7 100644
--- a/tests/test_migrate.py
+++ b/tests/test_migrate.py
@@ -1,8 +1,9 @@
 import os
+import shlex
 import shutil
-import unittest
 import subprocess
-import shlex
+import sys
+import unittest
 
 
 def run_cmd(cmd):
@@ -53,11 +54,11 @@ def test_alembic_version(self):
             self.assertTrue(isinstance(v, int))
 
     def test_migrate_upgrade(self):
-        (o, e, s) = run_cmd('python app.py db init')
+        (o, e, s) = run_cmd(sys.executable + ' app.py db init')
         self.assertTrue(s == 0)
-        (o, e, s) = run_cmd('python app.py db migrate')
+        (o, e, s) = run_cmd(sys.executable + ' app.py db migrate')
         self.assertTrue(s == 0)
-        (o, e, s) = run_cmd('python app.py db upgrade')
+        (o, e, s) = run_cmd(sys.executable + ' app.py db upgrade')
         self.assertTrue(s == 0)
 
         from .app import db, User
@@ -65,11 +66,11 @@ def test_migrate_upgrade(self):
         db.session.commit()
 
     def test_custom_directory(self):
-        (o, e, s) = run_cmd('python app_custom_directory.py db init')
+        (o, e, s) = run_cmd(sys.executable + ' app_custom_directory.py db init')
         self.assertTrue(s == 0)
-        (o, e, s) = run_cmd('python app_custom_directory.py db migrate')
+        (o, e, s) = run_cmd(sys.executable + ' app_custom_directory.py db migrate')
         self.assertTrue(s == 0)
-        (o, e, s) = run_cmd('python app_custom_directory.py db upgrade')
+        (o, e, s) = run_cmd(sys.executable + ' app_custom_directory.py db upgrade')
         self.assertTrue(s == 0)
 
         from .app_custom_directory import db, User
@@ -77,13 +78,13 @@ def test_custom_directory(self):
         db.session.commit()
 
     def test_compare_type(self):
-        (o, e, s) = run_cmd('python app_compare_type1.py db init')
+        (o, e, s) = run_cmd(sys.executable + ' app_compare_type1.py db init')
         self.assertTrue(s == 0)
-        (o, e, s) = run_cmd('python app_compare_type1.py db migrate')
+        (o, e, s) = run_cmd(sys.executable + ' app_compare_type1.py db migrate')
         self.assertTrue(s == 0)
-        (o, e, s) = run_cmd('python app_compare_type1.py db upgrade')
+        (o, e, s) = run_cmd(sys.executable + ' app_compare_type1.py db upgrade')
         self.assertTrue(s == 0)
-        (o, e, s) = run_cmd('python app_compare_type2.py db migrate')
+        (o, e, s) = run_cmd(sys.executable + ' app_compare_type2.py db migrate')
         self.assertTrue(s == 0)
         self.assertTrue(b'Detected type change from VARCHAR(length=128) '
                         b'to String(length=10)' in e)
diff --git a/tests/test_multidb_migrate.py b/tests/test_multidb_migrate.py
index e94e089..b2ae7d2 100644
--- a/tests/test_multidb_migrate.py
+++ b/tests/test_multidb_migrate.py
@@ -1,9 +1,10 @@
 import os
-import shutil
-import unittest
-import subprocess
 import shlex
+import shutil
 import sqlite3
+import subprocess
+import sys
+import unittest
 
 
 def run_cmd(cmd):
@@ -39,11 +40,11 @@ def tearDown(self):
             pass
 
     def test_multidb_migrate_upgrade(self):
-        (o, e, s) = run_cmd('python app_multidb.py db init --multidb')
+        (o, e, s) = run_cmd(sys.executable + ' app_multidb.py db init --multidb')
         self.assertTrue(s == 0)
-        (o, e, s) = run_cmd('python app_multidb.py db migrate')
+        (o, e, s) = run_cmd(sys.executable + ' app_multidb.py db migrate')
         self.assertTrue(s == 0)
-        (o, e, s) = run_cmd('python app_multidb.py db upgrade')
+        (o, e, s) = run_cmd(sys.executable + ' app_multidb.py db upgrade')
         self.assertTrue(s == 0)
 
         # ensure the tables are in the correct databases
@@ -70,7 +71,7 @@ def test_multidb_migrate_upgrade(self):
         db.session.commit()
 
         # ensure the downgrade works
-        (o, e, s) = run_cmd('python app_multidb.py db downgrade')
+        (o, e, s) = run_cmd(sys.executable + ' app_multidb.py db downgrade')
         self.assertTrue(s == 0)
 
         conn1 = sqlite3.connect('app1.db')
openSUSE Build Service is sponsored by