| 1 |
''' |
| 2 |
Tests related to with using context managers. |
| 3 |
''' |
| 4 |
|
| 5 |
from __future__ import absolute_import, print_function, unicode_literals |
| 6 |
|
| 7 |
from drmaa import Session |
| 8 |
|
| 9 |
|
| 10 |
def test_with_session(): |
| 11 |
"""'with' statement works with Session""" |
| 12 |
with Session() as s: |
| 13 |
print(s.version) |
| 14 |
print(s.contact) |
| 15 |
print(s.drmsInfo) |
| 16 |
print(s.drmaaImplementation) |
| 17 |
|
| 18 |
|
| 19 |
def test_with_jt(): |
| 20 |
"""'with' statement works with JobTemplate""" |
| 21 |
s = Session() |
| 22 |
s.initialize() |
| 23 |
with s.createJobTemplate() as jt: |
| 24 |
jt.remoteCommand = 'sleep' |
| 25 |
jt.args = ['10'] |
| 26 |
jid = s.runJob(jt) |
| 27 |
print(s.wait(jid)) |
| 28 |
s.exit() |