Skip to content

Commit cf1b7b3

Browse files
authored
Merge pull request #4284 from takluyver/i4283
More selective filename test in list_running_servers
2 parents 55d6f53 + adcb702 commit cf1b7b3

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

notebook/notebookapp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1839,7 +1839,7 @@ def list_running_servers(runtime_dir=None):
18391839
return
18401840

18411841
for file_name in os.listdir(runtime_dir):
1842-
if file_name.startswith('nbserver-'):
1842+
if re.match('nbserver-(.+).json', file_name):
18431843
with io.open(os.path.join(runtime_dir, file_name), encoding='utf-8') as f:
18441844
info = json.load(f)
18451845

notebook/tests/test_notebookapp.py

+9
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
from notebook.auth.security import passwd_check
2626
NotebookApp = notebookapp.NotebookApp
2727

28+
from .launchnotebook import NotebookTestBase
29+
2830

2931
def test_help_output():
3032
"""ipython notebook --help-all works"""
@@ -183,3 +185,10 @@ def list_running_servers(runtime_dir):
183185
app.start()
184186
nt.assert_equal(exc.exception.code, 1)
185187
nt.assert_equal(len(app.servers_shut_down), 0)
188+
189+
190+
class NotebookAppTests(NotebookTestBase):
191+
def test_list_running_servers(self):
192+
servers = list(notebookapp.list_running_servers())
193+
assert len(servers) >= 1
194+
assert self.port in {info['port'] for info in servers}

0 commit comments

Comments
 (0)