mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #29534 -- Made dbshell use rlwrap on Oracle if available.
This commit is contained in:
parent
9a88c6dd6a
commit
c6525bea9e
3 changed files with 41 additions and 0 deletions
33
tests/dbshell/test_oracle.py
Normal file
33
tests/dbshell/test_oracle.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
from unittest import mock, skipUnless
|
||||
|
||||
from django.db import connection
|
||||
from django.db.backends.oracle.client import DatabaseClient
|
||||
from django.test import SimpleTestCase
|
||||
|
||||
|
||||
@skipUnless(connection.vendor == 'oracle', 'Oracle tests')
|
||||
class OracleDbshellTests(SimpleTestCase):
|
||||
def _run_dbshell(self, rlwrap=False):
|
||||
"""Run runshell command and capture its arguments."""
|
||||
def _mock_subprocess_call(*args):
|
||||
self.subprocess_args = tuple(*args)
|
||||
return 0
|
||||
|
||||
client = DatabaseClient(connection)
|
||||
self.subprocess_args = None
|
||||
with mock.patch('subprocess.call', new=_mock_subprocess_call):
|
||||
with mock.patch('shutil.which', return_value='/usr/bin/rlwrap' if rlwrap else None):
|
||||
client.runshell()
|
||||
return self.subprocess_args
|
||||
|
||||
def test_without_rlwrap(self):
|
||||
self.assertEqual(
|
||||
self._run_dbshell(rlwrap=False),
|
||||
('sqlplus', '-L', connection._connect_string()),
|
||||
)
|
||||
|
||||
def test_with_rlwrap(self):
|
||||
self.assertEqual(
|
||||
self._run_dbshell(rlwrap=True),
|
||||
('/usr/bin/rlwrap', 'sqlplus', '-L', connection._connect_string()),
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue