@@ -90,38 +90,36 @@ def test_generate_config():
90
90
assert os .path .exists (os .path .join (td , 'jupyter_notebook_config.py' ))
91
91
92
92
#test if the version testin function works
93
- def test_pep440_version ():
94
-
95
- for version in [
93
+ @pytest .mark .parametrize (
94
+ 'version' , [
96
95
'4.1.0.b1' ,
97
96
'4.1.b1' ,
98
97
'4.2' ,
99
98
'X.y.z' ,
100
99
'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' , [
108
108
'4.1.1' ,
109
109
'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 )
113
114
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*)?$' )
117
116
118
117
def raise_on_bad_version (version ):
119
118
if not pep440re .match (version ):
120
119
raise ValueError ("Versions String does apparently not match Pep 440 specification, "
121
120
"which might lead to sdist and wheel being seen as 2 different release. "
122
121
"E.g: do not use dots for beta/alpha/rc markers." )
123
122
124
-
125
123
def test_current_version ():
126
124
raise_on_bad_version (__version__ )
127
125
@@ -139,7 +137,7 @@ def test_notebook_password():
139
137
assert nb .password != ''
140
138
passwd_check (nb .password , password )
141
139
142
- class TestingStopApp (notebookapp .NbserverStopApp ):
140
+ class StopAppTest (notebookapp .NbserverStopApp ):
143
141
"""For testing the logic of NbserverStopApp."""
144
142
def __init__ (self , ** kwargs ):
145
143
super ().__init__ (** kwargs )
@@ -168,15 +166,15 @@ def list_running_servers(runtime_dir):
168
166
169
167
# test stop with a match
170
168
with mock_servers :
171
- app = TestingStopApp ()
169
+ app = StopAppTest ()
172
170
app .initialize (['105' ])
173
171
app .start ()
174
172
assert len (app .servers_shut_down ) == 1
175
173
assert app .servers_shut_down [0 ]['port' ] == 105
176
174
177
175
# test no match
178
176
with mock_servers , patch ('os.kill' ) as os_kill :
179
- app = TestingStopApp ()
177
+ app = StopAppTest ()
180
178
app .initialize (['999' ])
181
179
with pytest .raises (SystemExit ) as exc :
182
180
app .start ()
0 commit comments