mirror of
https://github.com/django/django.git
synced 2025-08-30 15:27:40 +00:00
Replaced subprocess commands by run() wherever possible.
This commit is contained in:
parent
7bd9633320
commit
9386586f31
13 changed files with 42 additions and 42 deletions
|
@ -1,3 +1,4 @@
|
|||
from subprocess import CompletedProcess
|
||||
from unittest import mock, skipUnless
|
||||
|
||||
from django.db import connection
|
||||
|
@ -9,13 +10,13 @@ from django.test import SimpleTestCase
|
|||
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
|
||||
def _mock_subprocess_run(*args):
|
||||
self.subprocess_args = list(*args)
|
||||
return CompletedProcess(self.subprocess_args, 0)
|
||||
|
||||
client = DatabaseClient(connection)
|
||||
self.subprocess_args = None
|
||||
with mock.patch('subprocess.call', new=_mock_subprocess_call):
|
||||
with mock.patch('subprocess.run', new=_mock_subprocess_run):
|
||||
with mock.patch('shutil.which', return_value='/usr/bin/rlwrap' if rlwrap else None):
|
||||
client.runshell()
|
||||
return self.subprocess_args
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue