Skip to content

Commit 071d23f

Browse files
committed
linting
1 parent 57f9b9e commit 071d23f

File tree

5 files changed

+63
-64
lines changed

5 files changed

+63
-64
lines changed

anaconda-project.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ commands:
2020
lint:
2121
unix: |-
2222
isort -rc src \
23-
&& black src setup.py
23+
&& black src setup.py \
24+
&& python -m robot.tidy -r atest
2425
env_spec: rfjl37
2526

2627
atest:
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
*** Settings ***
2-
Library JupyterLibrary
2+
Library JupyterLibrary
33

4-
*** Test Cases ***
4+
*** Test Cases ***
55
Just import
6-
Log JupyterLibrary probably imported
6+
Log JupyterLibrary probably imported
Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,32 @@
11
*** Settings ***
2-
Library JupyterLibrary
3-
Library Process
4-
Test Teardown Terminate All Processes
2+
Test Teardown Terminate All Processes
3+
Library JupyterLibrary
4+
Library Process
55

6-
*** Test Cases ***
6+
*** Test Cases ***
77
Start one server
8-
${nbserver} = Start New Jupyter Server
9-
${ready} = Wait for Jupyter Server to be Ready
10-
Should be equal as integers ${ready} 1
11-
... msg=One server should be ready
12-
${terminated} = Terminate All Jupyter Servers
13-
Should be equal as integers ${terminated} 1
14-
... msg=One server should have been terminated
15-
${log} = Get Process Result ${nbserver} stderr=${True}
16-
Should Contain ${log} The Jupyter Notebook is running
17-
... msg=Log should contain expected status message
8+
${nbserver} = Start New Jupyter Server
9+
${ready} = Wait for Jupyter Server to be Ready
10+
Should be equal as integers ${ready} 1 msg=One server should be ready
11+
${terminated} = Terminate All Jupyter Servers
12+
Should be equal as integers ${terminated} 1 msg=One server should have been terminated
13+
${log} = Get Process Result ${nbserver} stderr=${True}
14+
Should Contain ${log} The Jupyter Notebook is running msg=Log should contain expected status message
1815

1916
Start three servers
20-
${nb1} = Start New Jupyter Server
21-
${nb2} = Start New Jupyter Server
22-
${ready} = Wait for Jupyter Server to be Ready ${nb2} ${nb1}
23-
Should be equal as integers ${ready} 2
24-
... msg=Three servers should be ready
25-
${nb3} = Start New Jupyter Server
26-
${terminated} = Terminate All Jupyter Servers
27-
Should be equal as integers ${terminated} 3
28-
... msg=Three servers should have been terminated
29-
${log1} = Get Process Result ${nb1} stderr=${True}
30-
Should Contain ${log1} The Jupyter Notebook is running
31-
... msg=Log should contain expected status message
32-
${log2} = Get Process Result ${nb2} stderr=${True}
33-
Should Contain ${log2} The Jupyter Notebook is running
34-
... msg=Log should contain expected status message
35-
${log3} = Get Process Result ${nb3} stderr=${True}
36-
Should Not Contain ${log3} The Jupyter Notebook is running
37-
... msg=Unawaited server log should not contain expected status message
38-
${terminated} = Terminate All Jupyter Servers
39-
Should be equal as integers ${terminated} 0
40-
... msg=No servers should have been terminated
41-
Run Keyword And Expect Error Only 0 of 3* Wait for Jupyter Server to be Ready ${nb2} ${nb1} ${nb3}
17+
${nb1} = Start New Jupyter Server
18+
${nb2} = Start New Jupyter Server
19+
${ready} = Wait for Jupyter Server to be Ready ${nb2} ${nb1}
20+
Should be equal as integers ${ready} 2 msg=Three servers should be ready
21+
${nb3} = Start New Jupyter Server
22+
${terminated} = Terminate All Jupyter Servers
23+
Should be equal as integers ${terminated} 3 msg=Three servers should have been terminated
24+
${log1} = Get Process Result ${nb1} stderr=${True}
25+
Should Contain ${log1} The Jupyter Notebook is running msg=Log should contain expected status message
26+
${log2} = Get Process Result ${nb2} stderr=${True}
27+
Should Contain ${log2} The Jupyter Notebook is running msg=Log should contain expected status message
28+
${log3} = Get Process Result ${nb3} stderr=${True}
29+
Should Not Contain ${log3} The Jupyter Notebook is running msg=Unawaited server log should not contain expected status message
30+
${terminated} = Terminate All Jupyter Servers
31+
Should be equal as integers ${terminated} 0 msg=No servers should have been terminated
32+
Run Keyword And Expect Error Only 0 of 3* Wait for Jupyter Server to be Ready ${nb2} ${nb1} ${nb3}

src/JupyterLibrary/core.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
from SeleniumLibrary import SeleniumLibrary
2-
31
from .keywords import server
2+
from SeleniumLibrary import SeleniumLibrary
43

54

65
class JupyterLibrary(SeleniumLibrary):
76
"""JupyterLibrary is a Jupyter testing library for Robot Framework."""
8-
def __init__(self, timeout=5.0, implicit_wait=0.0,
9-
run_on_failure='Capture Page Screenshot',
10-
screenshot_root_directory=None):
7+
8+
def __init__(
9+
self,
10+
timeout=5.0,
11+
implicit_wait=0.0,
12+
run_on_failure="Capture Page Screenshot",
13+
screenshot_root_directory=None,
14+
):
1115
"""JupyterLibrary can be imported with several optional arguments.
1216
- ``timeout``:
1317
Default value for `timeouts` used with ``Wait ...`` keywords.
@@ -23,8 +27,6 @@ def __init__(self, timeout=5.0, implicit_wait=0.0,
2327
timeout=5.0,
2428
implicit_wait=0.0,
2529
run_on_failure="Capture Page Screenshot",
26-
screenshot_root_directory=None
30+
screenshot_root_directory=None,
2731
)
28-
self.add_library_components([
29-
server.ServerKeywords(self)
30-
])
32+
self.add_library_components([server.ServerKeywords(self)])

src/JupyterLibrary/keywords/server.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import subprocess
2-
import time
3-
from six.moves.urllib.request import urlopen
4-
51
from robot.libraries.BuiltIn import BuiltIn
2+
from SeleniumLibrary.base import keyword
3+
from SeleniumLibrary.base import LibraryComponent
4+
from six.moves.urllib.request import urlopen
65
from tornado.escape import json_decode
76

8-
from SeleniumLibrary.base import keyword, LibraryComponent
7+
import subprocess
8+
import time
99

1010

1111
class NBServer(object):
@@ -19,7 +19,7 @@ class ServerKeywords(LibraryComponent):
1919
def start_new_jupyter_server(self, command="jupyter", *arguments, **configuration):
2020
""" Start a Jupyter server
2121
"""
22-
plib = BuiltIn().get_library_instance('Process')
22+
plib = BuiltIn().get_library_instance("Process")
2323
if not arguments:
2424
arguments = self.build_jupyter_server_arguments()
2525

@@ -38,7 +38,7 @@ def wait_for_jupyter_server_to_be_ready(self, *nbservers, **kwargs):
3838
interval = float(kwargs.get("interval", 0.25))
3939
retries = int(kwargs.get("retries", 20))
4040

41-
plib = BuiltIn().get_library_instance('Process')
41+
plib = BuiltIn().get_library_instance("Process")
4242

4343
if not nbservers:
4444
if not self._nbserver_handles:
@@ -63,17 +63,16 @@ def wait_for_jupyter_server_to_be_ready(self, *nbservers, **kwargs):
6363
time.sleep(interval)
6464
last_error = err
6565

66-
assert ready == len(nbservers), (
67-
"Only {} of {} servers were ready: {}".format(
68-
ready, len(nbservers), last_error
69-
))
66+
assert ready == len(nbservers), "Only {} of {} servers were ready: {}".format(
67+
ready, len(nbservers), last_error
68+
)
7069
return ready
7170

7271
@keyword
7372
def terminate_all_jupyter_servers(self, kill=False):
7473
""" Close all Jupyter servers started by JupyterLibrary
7574
"""
76-
plib = BuiltIn().get_library_instance('Process')
75+
plib = BuiltIn().get_library_instance("Process")
7776
terminated = 0
7877
for handle in self._nbserver_handles:
7978
plib.terminate_process(handle, kill=kill)
@@ -84,7 +83,13 @@ def terminate_all_jupyter_servers(self, kill=False):
8483
return terminated
8584

8685
def get_jupyter_servers(self):
87-
nbservers = list(map(json_decode, subprocess.check_output(
88-
["jupyter", "notebook", "list", "--json"]
89-
).decode("utf-8").strip().split("\n")))
86+
nbservers = list(
87+
map(
88+
json_decode,
89+
subprocess.check_output(["jupyter", "notebook", "list", "--json"])
90+
.decode("utf-8")
91+
.strip()
92+
.split("\n"),
93+
)
94+
)
9095
return {nbserver["pid"]: nbserver for nbserver in nbservers}

0 commit comments

Comments
 (0)