Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport PR #4284 on branch 5.7.x (More selective filename test in list_running_servers) #4285

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}