44import re
55import time
66
7+ import pytest
78from jupyterhub import orm
89from jupyterhub .objects import Hub , Server
910from jupyterhub .user import User
1011from traitlets import Unicode
11- import pytest
1212
1313from .. import BatchSpawnerRegexStates , JobStatus
1414
@@ -41,7 +41,7 @@ async def run_command(self, *args, **kwargs):
4141 print ("run:" , run_re )
4242 assert (
4343 run_re .search (cmd ) is not None
44- ), "Failed test: re={0 } cmd={1}" . format ( run_re , cmd )
44+ ), f "Failed test: re={ run_re } cmd={ cmd } "
4545 # Run command normally
4646 out = await super ().run_command (* args , ** kwargs )
4747 # Test that the command matches the expectations
@@ -51,7 +51,7 @@ async def run_command(self, *args, **kwargs):
5151 print ("out:" , out_re )
5252 assert (
5353 out_re .search (cmd ) is not None
54- ), "Failed output: re={0 } cmd={1 } out={2}" . format ( out_re , cmd , out )
54+ ), f "Failed output: re={ out_re } cmd={ cmd } out={ out } "
5555 return out
5656
5757
@@ -282,10 +282,10 @@ async def run_command(self, cmd, input=None, env=None):
282282 # Test the input
283283 run_re = cmd_expectlist .pop (0 )
284284 if run_re :
285- print ('run: "{}" [{}]' . format ( cmd , run_re ) )
285+ print (f 'run: "{ cmd } " [{ run_re } ]' )
286286 assert (
287287 run_re .search (cmd ) is not None
288- ), "Failed test: re={0 } cmd={1}" . format ( run_re , cmd )
288+ ), f "Failed test: re={ run_re } cmd={ cmd } "
289289 # Test the stdin - will only be the batch script. For
290290 # each regular expression in batch_script_re_list, assert that
291291 # each re in that list matches the batch script.
@@ -294,7 +294,7 @@ async def run_command(self, cmd, input=None, env=None):
294294 for match_re in batch_script_re_list :
295295 assert (
296296 match_re .search (batch_script ) is not None
297- ), "Batch script does not match {}" . format ( match_re )
297+ ), f "Batch script does not match { match_re } "
298298 # Return expected output.
299299 out = out_list .pop (0 )
300300 print (" --> " + out )
@@ -345,11 +345,11 @@ async def test_torque(db, event_loop):
345345 ), # pending
346346 (
347347 re .compile (r"sudo.*qstat" ),
348- "<job_state>R</job_state><exec_host>{}/1</exec_host>" . format ( testhost ) ,
348+ f "<job_state>R</job_state><exec_host>{ testhost } /1</exec_host>" ,
349349 ), # running
350350 (
351351 re .compile (r"sudo.*qstat" ),
352- "<job_state>R</job_state><exec_host>{}/1</exec_host>" . format ( testhost ) ,
352+ f "<job_state>R</job_state><exec_host>{ testhost } /1</exec_host>" ,
353353 ), # running
354354 (re .compile (r"sudo.*qdel" ), "STOP" ),
355355 (re .compile (r"sudo.*qstat" ), "" ),
@@ -387,11 +387,11 @@ async def test_moab(db, event_loop):
387387 (re .compile (r"sudo.*mdiag" ), 'State="Idle"' ), # pending
388388 (
389389 re .compile (r"sudo.*mdiag" ),
390- 'State="Running" AllocNodeList="{}"' . format ( testhost ) ,
390+ f 'State="Running" AllocNodeList="{ testhost } "' ,
391391 ), # running
392392 (
393393 re .compile (r"sudo.*mdiag" ),
394- 'State="Running" AllocNodeList="{}"' . format ( testhost ) ,
394+ f 'State="Running" AllocNodeList="{ testhost } "' ,
395395 ), # running
396396 (re .compile (r"sudo.*mjobctl.*-c" ), "STOP" ),
397397 (re .compile (r"sudo.*mdiag" ), "" ),
@@ -429,11 +429,11 @@ async def test_pbs(db, event_loop):
429429 (re .compile (r"sudo.*qstat" ), "job_state = Q" ), # pending
430430 (
431431 re .compile (r"sudo.*qstat" ),
432- "job_state = R\n exec_host = {}/2*1" . format ( testhost ) ,
432+ f "job_state = R\n exec_host = { testhost } /2*1" ,
433433 ), # running
434434 (
435435 re .compile (r"sudo.*qstat" ),
436- "job_state = R\n exec_host = {}/2*1" . format ( testhost ) ,
436+ f "job_state = R\n exec_host = { testhost } /2*1" ,
437437 ), # running
438438 (re .compile (r"sudo.*qdel" ), "STOP" ),
439439 (re .compile (r"sudo.*qstat" ), "" ),
@@ -556,11 +556,11 @@ async def test_condor(db, event_loop):
556556 script = [
557557 (
558558 re .compile (r"sudo.*condor_submit" ),
559- "submitted to cluster {}" . format ( str (testjob )) ,
559+ f "submitted to cluster { str (testjob )} " ,
560560 ),
561561 (re .compile (r"sudo.*condor_q" ), "1," ), # pending
562- (re .compile (r"sudo.*condor_q" ), "2, @{}" . format ( testhost ) ), # runing
563- (re .compile (r"sudo.*condor_q" ), "2, @{}" . format ( testhost ) ),
562+ (re .compile (r"sudo.*condor_q" ), f "2, @{ testhost } " ), # runing
563+ (re .compile (r"sudo.*condor_q" ), f "2, @{ testhost } " ),
564564 (re .compile (r"sudo.*condor_rm" ), "STOP" ),
565565 (re .compile (r"sudo.*condor_q" ), "" ),
566566 ]
@@ -594,11 +594,11 @@ async def test_lfs(db, event_loop):
594594 script = [
595595 (
596596 re .compile (r"sudo.*bsub" ),
597- "Job <{}> is submitted to default queue <normal>" . format ( str ( testjob )) ,
597+ f "Job <{ str ( testjob ) } > is submitted to default queue <normal>" ,
598598 ),
599599 (re .compile (r"sudo.*bjobs" ), "PEND " ), # pending
600- (re .compile (r"sudo.*bjobs" ), "RUN {}" . format ( testhost ) ), # running
601- (re .compile (r"sudo.*bjobs" ), "RUN {}" . format ( testhost ) ),
600+ (re .compile (r"sudo.*bjobs" ), f "RUN { testhost } " ), # running
601+ (re .compile (r"sudo.*bjobs" ), f "RUN { testhost } " ),
602602 (re .compile (r"sudo.*bkill" ), "STOP" ),
603603 (re .compile (r"sudo.*bjobs" ), "" ),
604604 ]
0 commit comments