From 34b4f7ed6d55338291415158982a36a7dae7b85e Mon Sep 17 00:00:00 2001 From: Karolina Surma Date: Mon, 22 Mar 2021 09:36:20 +0100 Subject: [PATCH 1/2] Fix skipped tests & remove deprecation warnings --- notebook/tests/test_notebookapp.py | 38 ++++++++++++++---------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/notebook/tests/test_notebookapp.py b/notebook/tests/test_notebookapp.py index d84852e44..a852c2346 100644 --- a/notebook/tests/test_notebookapp.py +++ b/notebook/tests/test_notebookapp.py @@ -90,30 +90,29 @@ def test_generate_config(): assert os.path.exists(os.path.join(td, 'jupyter_notebook_config.py')) #test if the version testin function works -def test_pep440_version(): - - for version in [ +@pytest.mark.parametrize( + 'version', [ '4.1.0.b1', '4.1.b1', '4.2', 'X.y.z', '1.2.3.dev1.post2', - ]: - def loc(): - with pytest.raises(ValueError): - raise_on_bad_version(version) - yield loc - - for version in [ + ] +) +def test_pep440_bad_version(version): + with pytest.raises(ValueError): + raise_on_bad_version(version) + +@pytest.mark.parametrize( + 'version', [ '4.1.1', '4.2.1b3', - ]: - - yield (raise_on_bad_version, version) + ] +) +def test_pep440_good_version(version): + raise_on_bad_version(version) - - -pep440re = re.compile('^(\d+)\.(\d+)\.(\d+((a|b|rc)\d+)?)(\.post\d+)?(\.dev\d*)?$') +pep440re = re.compile(r'^(\d+)\.(\d+)\.(\d+((a|b|rc)\d+)?)(\.post\d+)?(\.dev\d*)?$') def raise_on_bad_version(version): if not pep440re.match(version): @@ -121,7 +120,6 @@ def raise_on_bad_version(version): "which might lead to sdist and wheel being seen as 2 different release. " "E.g: do not use dots for beta/alpha/rc markers.") - def test_current_version(): raise_on_bad_version(__version__) @@ -139,7 +137,7 @@ def test_notebook_password(): assert nb.password != '' passwd_check(nb.password, password) -class TestingStopApp(notebookapp.NbserverStopApp): +class StopTestApp(notebookapp.NbserverStopApp): """For testing the logic of NbserverStopApp.""" def __init__(self, **kwargs): super().__init__(**kwargs) @@ -168,7 +166,7 @@ def test_notebook_stop(): # test stop with a match with mock_servers: - app = TestingStopApp() + app = StopTestApp() app.initialize(['105']) app.start() assert len(app.servers_shut_down) == 1 @@ -176,7 +174,7 @@ def test_notebook_stop(): # test no match with mock_servers, patch('os.kill') as os_kill: - app = TestingStopApp() + app = StopTestApp() app.initialize(['999']) with pytest.raises(SystemExit) as exc: app.start() From 0723596c540de244529b8c489ed5bd1656d36d53 Mon Sep 17 00:00:00 2001 From: Karolina Surma Date: Tue, 23 Mar 2021 08:08:01 +0100 Subject: [PATCH 2/2] Rename StopTestApp -> StopAppTest to reflect the original class better. --- notebook/tests/test_notebookapp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/notebook/tests/test_notebookapp.py b/notebook/tests/test_notebookapp.py index a852c2346..d48501b93 100644 --- a/notebook/tests/test_notebookapp.py +++ b/notebook/tests/test_notebookapp.py @@ -137,7 +137,7 @@ def test_notebook_password(): assert nb.password != '' passwd_check(nb.password, password) -class StopTestApp(notebookapp.NbserverStopApp): +class StopAppTest(notebookapp.NbserverStopApp): """For testing the logic of NbserverStopApp.""" def __init__(self, **kwargs): super().__init__(**kwargs) @@ -166,7 +166,7 @@ def test_notebook_stop(): # test stop with a match with mock_servers: - app = StopTestApp() + app = StopAppTest() app.initialize(['105']) app.start() assert len(app.servers_shut_down) == 1 @@ -174,7 +174,7 @@ def test_notebook_stop(): # test no match with mock_servers, patch('os.kill') as os_kill: - app = StopTestApp() + app = StopAppTest() app.initialize(['999']) with pytest.raises(SystemExit) as exc: app.start()