@@ -101,7 +101,7 @@ def parse_feature(basedir, filename, encoding="utf-8"):
101
101
multiline_step = False
102
102
prev_line = None
103
103
104
- with io . open (abs_filename , "rt" , encoding = encoding ) as f :
104
+ with open (abs_filename , encoding = encoding ) as f :
105
105
content = f .read ()
106
106
107
107
for line_number , line in enumerate (content .splitlines (), start = 1 ):
@@ -170,14 +170,14 @@ def parse_feature(basedir, filename, encoding="utf-8"):
170
170
except exceptions .ExamplesNotValidError as exc :
171
171
if scenario :
172
172
raise exceptions .FeatureError (
173
- """ Scenario has not valid examples. {0}""" . format ( exc .args [0 ]) ,
173
+ f" Scenario has not valid examples. { exc .args [0 ]} " ,
174
174
line_number ,
175
175
clean_line ,
176
176
filename ,
177
177
)
178
178
else :
179
179
raise exceptions .FeatureError (
180
- """ Feature has not valid examples. {0}""" . format ( exc .args [0 ]) ,
180
+ f" Feature has not valid examples. { exc .args [0 ]} " ,
181
181
line_number ,
182
182
clean_line ,
183
183
filename ,
@@ -195,7 +195,7 @@ def parse_feature(basedir, filename, encoding="utf-8"):
195
195
return feature
196
196
197
197
198
- class Feature ( object ) :
198
+ class Feature :
199
199
"""Feature."""
200
200
201
201
def __init__ (self , scenarios , filename , rel_filename , name , tags , examples , background , line_number , description ):
@@ -213,7 +213,7 @@ def __init__(self, scenarios, filename, rel_filename, name, tags, examples, back
213
213
self .background = background
214
214
215
215
216
- class Scenario ( object ) :
216
+ class Scenario :
217
217
218
218
"""Scenario."""
219
219
@@ -283,14 +283,14 @@ def validate(self):
283
283
example_params = self .get_example_params ()
284
284
if params and example_params and params != example_params :
285
285
raise exceptions .ScenarioExamplesNotValidError (
286
- """Scenario "{0 }" in the feature "{1 }" has not valid examples. """
287
- """Set of step parameters {2 } should match set of example values {3 }.""" .format (
286
+ """Scenario "{}" in the feature "{}" has not valid examples. """
287
+ """Set of step parameters {} should match set of example values {}.""" .format (
288
288
self .name , self .feature .filename , sorted (params ), sorted (example_params )
289
289
)
290
290
)
291
291
292
292
293
- class Step ( object ) :
293
+ class Step :
294
294
295
295
"""Step."""
296
296
@@ -345,15 +345,15 @@ def name(self, value):
345
345
346
346
def __str__ (self ):
347
347
"""Full step name including the type."""
348
- return '{type} "{name}"' . format ( type = self .type .capitalize (), name = self .name )
348
+ return f' { self .type .capitalize ()} " { self .name } "'
349
349
350
350
@property
351
351
def params (self ):
352
352
"""Get step params."""
353
353
return tuple (frozenset (STEP_PARAM_RE .findall (self .name )))
354
354
355
355
356
- class Background ( object ) :
356
+ class Background :
357
357
358
358
"""Background."""
359
359
@@ -373,7 +373,7 @@ def add_step(self, step):
373
373
self .steps .append (step )
374
374
375
375
376
- class Examples ( object ) :
376
+ class Examples :
377
377
378
378
"""Example table."""
379
379
@@ -407,7 +407,7 @@ def add_example_row(self, param, values):
407
407
"""
408
408
if param in self .example_params :
409
409
raise exceptions .ExamplesNotValidError (
410
- """Example rows should contain unique parameters. "{0 }" appeared more than once""" . format ( param )
410
+ f """Example rows should contain unique parameters. "{ param } " appeared more than once"""
411
411
)
412
412
self .example_params .append (param )
413
413
self .vertical_examples .append (values )
@@ -454,7 +454,7 @@ def get_tags(line):
454
454
"""
455
455
if not line or not line .strip ().startswith ("@" ):
456
456
return set ()
457
- return set (( tag .lstrip ("@" ) for tag in line .strip ().split (" @" ) if len (tag ) > 1 ))
457
+ return { tag .lstrip ("@" ) for tag in line .strip ().split (" @" ) if len (tag ) > 1 }
458
458
459
459
460
460
STEP_PARAM_RE = re .compile (r"\<(.+?)\>" )
0 commit comments