Skip to content

Commit

Permalink
Merge pull request #4285 from meeseeksmachine/auto-backport-of-pr-428…
Browse files Browse the repository at this point in the history
…4-on-5.7.x

Backport PR #4284 on branch 5.7.x (More selective filename test in list_running_servers)
  • Loading branch information
takluyver authored Dec 17, 2018
2 parents 546ac59 + 3941536 commit 7b0ed75
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion notebook/notebookapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1831,7 +1831,7 @@ def list_running_servers(runtime_dir=None):
return

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

Expand Down
9 changes: 9 additions & 0 deletions notebook/tests/test_notebookapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
from notebook.auth.security import passwd_check
NotebookApp = notebookapp.NotebookApp

from .launchnotebook import NotebookTestBase


def test_help_output():
"""ipython notebook --help-all works"""
Expand Down Expand Up @@ -183,3 +185,10 @@ def list_running_servers(runtime_dir):
app.start()
nt.assert_equal(exc.exception.code, 1)
nt.assert_equal(len(app.servers_shut_down), 0)


class NotebookAppTests(NotebookTestBase):
def test_list_running_servers(self):
servers = list(notebookapp.list_running_servers())
assert len(servers) >= 1
assert self.port in {info['port'] for info in servers}

0 comments on commit 7b0ed75

Please sign in to comment.