Skip to content

Commit 502469a

Browse files
committed
test: removed deprecation
1 parent d391adc commit 502469a

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

src/DIRAC/Resources/Computing/test/Test_HTCondorCEComputingElement.py

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
"""
33
tests for HTCondorCEComputingElement module
44
"""
5-
from __future__ import absolute_import
6-
from __future__ import division
7-
from __future__ import print_function
8-
95
import pytest
106

117
from DIRAC.Resources.Computing import HTCondorCEComputingElement as HTCE
@@ -96,8 +92,7 @@ def test_getJobStatusBatchSystem(mocker):
9692
patchPopen.return_value.communicate.side_effect = [("\n".join(STATUS_LINES), ""), ("\n".join(HISTORY_LINES), "")]
9793
patchPopen.return_value.returncode = 0
9894

99-
with patchPopen:
100-
ret = Condor.Condor().getJobStatus(JobIDList=["123.0", "123.1", "123.2", "333.3"])
95+
ret = Condor.Condor().getJobStatus(JobIDList=["123.0", "123.1", "123.2", "333.3"])
10196

10297
expectedResults = {
10398
"123.0": "Done",
@@ -122,17 +117,16 @@ def test__writeSub(mocker, localSchedd, optionsNotExpected, optionsExpected):
122117
htce.useLocalSchedd = localSchedd
123118
subFileMock = mocker.Mock()
124119

125-
patchFdopen = mocker.patch(MODNAME + ".os.fdopen", return_value=subFileMock)
126-
patchMkstemp = mocker.patch(MODNAME + ".tempfile.mkstemp", return_value=("os", "pilotName"))
127-
patchMkdir = mocker.patch(MODNAME + ".mkDir")
120+
mocker.patch(MODNAME + ".os.fdopen", return_value=subFileMock)
121+
mocker.patch(MODNAME + ".tempfile.mkstemp", return_value=("os", "pilotName"))
122+
mocker.patch(MODNAME + ".mkDir")
128123

129-
with patchFdopen, patchMkstemp, patchMkdir:
130-
htce._HTCondorCEComputingElement__writeSub("dirac-install", 42, "", 1) # pylint: disable=E1101
131-
for option in optionsNotExpected:
132-
# the three [0] are: call_args_list[firstCall][ArgsArgumentsTuple][FirstArgsArgument]
133-
assert option not in subFileMock.write.call_args_list[0][0][0]
134-
for option in optionsExpected:
135-
assert option in subFileMock.write.call_args_list[0][0][0]
124+
htce._HTCondorCEComputingElement__writeSub("dirac-install", 42, "", 1) # pylint: disable=E1101
125+
for option in optionsNotExpected:
126+
# the three [0] are: call_args_list[firstCall][ArgsArgumentsTuple][FirstArgsArgument]
127+
assert option not in subFileMock.write.call_args_list[0][0][0]
128+
for option in optionsExpected:
129+
assert option in subFileMock.write.call_args_list[0][0][0]
136130

137131

138132
@pytest.mark.parametrize(
@@ -166,13 +160,12 @@ def test_submitJob(setUp, mocker, localSchedd, expected):
166160
htce.ceName = ceName
167161

168162
execMock = mocker.patch(MODNAME + ".executeGridCommand", return_value=S_OK((0, "123.0 - 123.0")))
169-
writeSubMock = mocker.patch(
163+
mocker.patch(
170164
MODNAME + ".HTCondorCEComputingElement._HTCondorCEComputingElement__writeSub", return_value="dirac_pilot"
171165
)
172-
osMock = mocker.patch(MODNAME + ".os")
166+
mocker.patch(MODNAME + ".os")
173167

174-
with execMock, writeSubMock, osMock:
175-
result = htce.submitJob("pilot", "proxy", 1)
168+
result = htce.submitJob("pilot", "proxy", 1)
176169

177170
assert result["OK"] is True
178171
assert " ".join(execMock.call_args_list[0][0][1]) == expected
@@ -199,8 +192,7 @@ def test_killJob(setUp, mocker, jobIDList, jobID, ret, success, local):
199192
htce._reset()
200193

201194
commandsMock = mocker.patch(MODNAME + ".commands.getstatusoutput", return_value=(ret, ""))
202-
with commandsMock:
203-
ret = htce.killJob(jobIDList=jobIDList)
195+
ret = htce.killJob(jobIDList=jobIDList)
204196

205197
assert ret["OK"] == success
206198
if jobID:

0 commit comments

Comments
 (0)