mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 08:56:34 +03:00
Added test to verify _psycopg can be imported
This commit is contained in:
parent
b12f6a9135
commit
3dad8344c0
2
NEWS
2
NEWS
|
@ -15,6 +15,8 @@ What's new in psycopg 2.5.4
|
||||||
- Don't ignore silently the `cursor.callproc` argument without a length.
|
- Don't ignore silently the `cursor.callproc` argument without a length.
|
||||||
- Added a few errors missing from `~psycopg2.errorcodes`, defined by
|
- Added a few errors missing from `~psycopg2.errorcodes`, defined by
|
||||||
PostgreSQL but not documented.
|
PostgreSQL but not documented.
|
||||||
|
- Make sure the internal `_psycopg.so` module can be imported stand-alone
|
||||||
|
(to allow modules juggling such as the one described in :ticket:`#201`).
|
||||||
|
|
||||||
|
|
||||||
What's new in psycopg 2.5.3
|
What's new in psycopg 2.5.3
|
||||||
|
|
|
@ -22,8 +22,12 @@
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
# License for more details.
|
# License for more details.
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from subprocess import Popen
|
||||||
|
|
||||||
from testutils import unittest, skip_before_python, skip_before_postgres
|
from testutils import unittest, skip_before_python, skip_before_postgres
|
||||||
from testutils import ConnectingTestCase, skip_copy_if_green
|
from testutils import ConnectingTestCase, skip_copy_if_green, script_to_py3
|
||||||
|
|
||||||
import psycopg2
|
import psycopg2
|
||||||
|
|
||||||
|
@ -295,6 +299,27 @@ class ExceptionsTestCase(ConnectingTestCase):
|
||||||
self.assert_(e1.cursor is None)
|
self.assert_(e1.cursor is None)
|
||||||
|
|
||||||
|
|
||||||
|
class TestExtensionModule(unittest.TestCase):
|
||||||
|
def test_import_internal(self):
|
||||||
|
# check that the internal package can be imported "naked"
|
||||||
|
# we may break this property if there is a compelling reason to do so,
|
||||||
|
# however having it allows for some import juggling such as the one
|
||||||
|
# required in ticket #201.
|
||||||
|
pkgdir = os.path.dirname(psycopg2.__file__)
|
||||||
|
pardir = os.path.dirname(pkgdir)
|
||||||
|
self.assert_(pardir in sys.path)
|
||||||
|
script = ("""
|
||||||
|
import sys
|
||||||
|
sys.path.remove(%r)
|
||||||
|
sys.path.insert(0, %r)
|
||||||
|
import _psycopg
|
||||||
|
""" % (pardir, pkgdir))
|
||||||
|
|
||||||
|
proc = Popen([sys.executable, '-c', script_to_py3(script)])
|
||||||
|
proc.communicate()
|
||||||
|
self.assertEqual(0, proc.returncode)
|
||||||
|
|
||||||
|
|
||||||
def test_suite():
|
def test_suite():
|
||||||
return unittest.TestLoader().loadTestsFromName(__name__)
|
return unittest.TestLoader().loadTestsFromName(__name__)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user