@@ -90,38 +90,36 @@ def test_generate_config():
9090 assert os .path .exists (os .path .join (td , 'jupyter_notebook_config.py' ))
9191
9292#test if the version testin function works
93- def test_pep440_version ():
94-
95- for version in [
93+ @pytest .mark .parametrize (
94+ 'version' , [
9695 '4.1.0.b1' ,
9796 '4.1.b1' ,
9897 '4.2' ,
9998 'X.y.z' ,
10099 '1.2.3.dev1.post2' ,
101- ]:
102- def loc ():
103- with pytest .raises (ValueError ):
104- raise_on_bad_version (version )
105- yield loc
106-
107- for version in [
100+ ]
101+ )
102+ def test_pep440_bad_version (version ):
103+ with pytest .raises (ValueError ):
104+ raise_on_bad_version (version )
105+
106+ @pytest .mark .parametrize (
107+ 'version' , [
108108 '4.1.1' ,
109109 '4.2.1b3' ,
110- ]:
111-
112- yield (raise_on_bad_version , version )
110+ ]
111+ )
112+ def test_pep440_good_version (version ):
113+ raise_on_bad_version (version )
113114
114-
115-
116- pep440re = re .compile ('^(\d+)\.(\d+)\.(\d+((a|b|rc)\d+)?)(\.post\d+)?(\.dev\d*)?$' )
115+ pep440re = re .compile (r'^(\d+)\.(\d+)\.(\d+((a|b|rc)\d+)?)(\.post\d+)?(\.dev\d*)?$' )
117116
118117def raise_on_bad_version (version ):
119118 if not pep440re .match (version ):
120119 raise ValueError ("Versions String does apparently not match Pep 440 specification, "
121120 "which might lead to sdist and wheel being seen as 2 different release. "
122121 "E.g: do not use dots for beta/alpha/rc markers." )
123122
124-
125123def test_current_version ():
126124 raise_on_bad_version (__version__ )
127125
@@ -139,7 +137,7 @@ def test_notebook_password():
139137 assert nb .password != ''
140138 passwd_check (nb .password , password )
141139
142- class TestingStopApp (notebookapp .NbserverStopApp ):
140+ class StopAppTest (notebookapp .NbserverStopApp ):
143141 """For testing the logic of NbserverStopApp."""
144142 def __init__ (self , ** kwargs ):
145143 super ().__init__ (** kwargs )
@@ -168,15 +166,15 @@ def list_running_servers(runtime_dir):
168166
169167 # test stop with a match
170168 with mock_servers :
171- app = TestingStopApp ()
169+ app = StopAppTest ()
172170 app .initialize (['105' ])
173171 app .start ()
174172 assert len (app .servers_shut_down ) == 1
175173 assert app .servers_shut_down [0 ]['port' ] == 105
176174
177175 # test no match
178176 with mock_servers , patch ('os.kill' ) as os_kill :
179- app = TestingStopApp ()
177+ app = StopAppTest ()
180178 app .initialize (['999' ])
181179 with pytest .raises (SystemExit ) as exc :
182180 app .start ()
0 commit comments