[Python-modules-commits] [python-testing.postgresql] 03/07: From: Takeshi KOMIYA <i.tkomiya at gmail.com> Date: Fri, 5 Feb 2016 21:56:57 +0900 Subject: [PATCH] Use utility methods of testing.common.database >= 1.1.0 Origin: upstream, https://github.com/tk0miya/testing.postgresql/commit/738c8eb19a4b064dd74ff851c379dd1cbf11bc65.patch Applied-Upstream: commit:738c8eb19a4b064dd74ff851c379dd1cbf11bc65

Dominik George natureshadow-guest at moszumanska.debian.org
Thu Oct 13 11:57:34 UTC 2016


This is an automated email from the git hooks/post-receive script.

natureshadow-guest pushed a commit to branch master
in repository python-testing.postgresql.

commit 659829a63f423c495e6fbcc7a053235426234513
Author: Dominik George <nik at naturalnet.de>
Date:   Thu Oct 13 13:40:10 2016 +0200

    From: Takeshi KOMIYA <i.tkomiya at gmail.com>
    Date: Fri, 5 Feb 2016 21:56:57 +0900
    Subject: [PATCH] Use utility methods of testing.common.database >= 1.1.0
    Origin: upstream, https://github.com/tk0miya/testing.postgresql/commit/738c8eb19a4b064dd74ff851c379dd1cbf11bc65.patch
    Applied-Upstream: commit:738c8eb19a4b064dd74ff851c379dd1cbf11bc65
---
 setup.py                 |  2 +-
 tests/test_postgresql.py | 41 ++++++++++++++---------------------------
 2 files changed, 15 insertions(+), 28 deletions(-)

diff --git a/setup.py b/setup.py
index 08095cd..9e95298 100644
--- a/setup.py
+++ b/setup.py
@@ -18,7 +18,7 @@ classifiers = [
     "Topic :: Software Development :: Testing",
 ]
 
-install_requires = ['testing.common.database', 'pg8000 >= 1.10']
+install_requires = ['testing.common.database >= 1.1.0', 'pg8000 >= 1.10']
 if sys.version_info < (2, 7):
     install_requires.append('unittest2')
 
diff --git a/tests/test_postgresql.py b/tests/test_postgresql.py
index 29e2b7e..b3603a2 100644
--- a/tests/test_postgresql.py
+++ b/tests/test_postgresql.py
@@ -47,38 +47,31 @@ class TestPostgresql(unittest.TestCase):
             conn.close()
         finally:
             # shutting down
-            pid = pgsql.pid
-            self.assertTrue(pid)
-            os.kill(pid, 0)  # process is alive
+            pid = pgsql.server_pid
+            self.assertTrue(pgsql.is_alive())
 
             pgsql.stop()
             sleep(1)
 
-            self.assertIsNone(pgsql.pid)
+            self.assertFalse(pgsql.is_alive())
             with self.assertRaises(OSError):
                 os.kill(pid, 0)  # process is down
 
     def test_stop(self):
         # start postgresql server
         pgsql = testing.postgresql.Postgresql()
-        self.assertIsNotNone(pgsql.pid)
         self.assertTrue(os.path.exists(pgsql.base_dir))
-        pid = pgsql.pid
-        os.kill(pid, 0)  # process is alive
+        self.assertTrue(pgsql.is_alive())
 
         # call stop()
         pgsql.stop()
-        self.assertIsNone(pgsql.pid)
         self.assertFalse(os.path.exists(pgsql.base_dir))
-        with self.assertRaises(OSError):
-            os.kill(pid, 0)  # process is down
+        self.assertFalse(pgsql.is_alive())
 
         # call stop() again
         pgsql.stop()
-        self.assertIsNone(pgsql.pid)
         self.assertFalse(os.path.exists(pgsql.base_dir))
-        with self.assertRaises(OSError):
-            os.kill(pid, 0)  # process is down
+        self.assertFalse(pgsql.is_alive())
 
         # delete postgresql object after stop()
         del pgsql
@@ -98,20 +91,17 @@ class TestPostgresql(unittest.TestCase):
             self.assertIsNotNone(conn)
             conn.close()
 
-            pid = pgsql.pid
-            os.kill(pid, 0)  # process is alive
+            self.assertTrue(pgsql.is_alive())
 
-        self.assertIsNone(pgsql.pid)
-        with self.assertRaises(OSError):
-            os.kill(pid, 0)  # process is down
+        self.assertFalse(pgsql.is_alive())
 
     def test_multiple_postgresql(self):
         pgsql1 = testing.postgresql.Postgresql()
         pgsql2 = testing.postgresql.Postgresql()
-        self.assertNotEqual(pgsql1.pid, pgsql2.pid)
+        self.assertNotEqual(pgsql1.server_pid, pgsql2.server_pid)
 
-        os.kill(pgsql1.pid, 0)  # process is alive
-        os.kill(pgsql2.pid, 0)  # process is alive
+        self.assertTrue(pgsql1.is_alive())
+        self.assertTrue(pgsql2.is_alive())
 
     def test_postgresql_is_not_found(self):
         try:
@@ -135,21 +125,18 @@ class TestPostgresql(unittest.TestCase):
         else:
             os.wait()
             sleep(1)
-            self.assertTrue(pgsql.pid)
-            os.kill(pgsql.pid, 0)  # process is alive (delete pgsql obj in child does not effect)
+            self.assertTrue(pgsql.is_alive())  # process is alive (delete pgsql obj in child does not effect)
 
     def test_stop_on_child_process(self):
         pgsql = testing.postgresql.Postgresql()
         if os.fork() == 0:
             pgsql.stop()
-            self.assertTrue(pgsql.pid)
-            os.kill(pgsql.pid, 0)  # process is alive (calling stop() is ignored)
+            os.kill(pgsql.server_pid, 0)  # process is alive (calling stop() is ignored)
             os.kill(os.getpid(), signal.SIGTERM)  # exit tests FORCELY
         else:
             os.wait()
             sleep(1)
-            self.assertTrue(pgsql.pid)
-            os.kill(pgsql.pid, 0)  # process is alive (calling stop() in child is ignored)
+            self.assertTrue(pgsql.is_alive())  # process is alive (calling stop() in child is ignored)
 
     def test_copy_data_from(self):
         try:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-testing.postgresql.git



More information about the Python-modules-commits mailing list