Skip to content

Commit cc12c31

Browse files
committed
Minor tweaks to update #197
- Formatting/blacken - Modern pytest style asserts and 'raises' use
1 parent ca2fd9b commit cc12c31

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

invoke/collection.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ def add_collection(self, coll, name=None, default=None):
310310
self.collections[name] = coll
311311
if default:
312312
if self.default:
313-
msg = "'%s' cannot be the default because '%s' already is!"
314-
raise ValueError(msg % (name, self.default))
313+
msg = "'{}' cannot be the default because '{}' already is!"
314+
raise ValueError(msg.format(name, self.default))
315315
self.default = coll
316316

317317
def _split_path(self, path):
@@ -383,7 +383,9 @@ def task_with_config(self, name):
383383
if not self.default:
384384
raise ValueError("This collection has no default task.")
385385
if isinstance(self.default, Collection):
386-
return self._task_with_merged_config(self.default.name, '', ours)
386+
return self._task_with_merged_config(
387+
self.default.name, "", ours
388+
)
387389
else:
388390
return self[self.default], ours
389391
# Normalize name to the format we're expecting

tests/collection.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,10 @@ def can_take_module_objects(self):
363363
assert "integration" in self.c.collections
364364

365365
def allows_specifying_defaultness(self):
366-
collection = Collection('foo')
366+
collection = Collection("foo")
367367
self.c.add_collection(collection, default=True)
368-
eq_(self.c.default, collection)
368+
assert self.c.default is collection
369369

370-
@raises(ValueError)
371370
def raises_ValueError_if_collection_without_name(self):
372371
# Aka non-root collections must either have an explicit name given
373372
# via kwarg, have a name attribute set, or be a module with
@@ -382,12 +381,12 @@ def raises_ValueError_if_collection_named_same_as_task(self):
382381
with raises(ValueError):
383382
self.c.add_collection(Collection("sub"))
384383

385-
@raises(ValueError)
386384
def raises_ValueError_on_multiple_defaults(self):
387385
t1 = Task(_func, default=True)
388-
self.c.add_task(t1, 'foo')
389-
collection = Collection('bar')
390-
self.c.add_collection(collection, default=True)
386+
self.c.add_task(t1, "foo")
387+
collection = Collection("bar")
388+
with raises(ValueError):
389+
self.c.add_collection(collection, default=True)
391390

392391
class getitem:
393392
"__getitem__"
@@ -422,10 +421,10 @@ def honors_own_default_task_with_no_args(self):
422421

423422
def honors_own_default_subcollection(self):
424423
task = Task(_func, default=True)
425-
sub = Collection('sub')
424+
sub = Collection("sub")
426425
sub.add_task(task, default=True)
427426
self.c.add_collection(sub, default=True)
428-
eq_(self.c[''], task)
427+
assert self.c[""] == task
429428

430429
def honors_subcollection_default_tasks_on_subcollection_name(self):
431430
sub = Collection.from_module(load("decorators"))

0 commit comments

Comments
 (0)