Skip to content

Commit e5516bc

Browse files
testlib: remove support for setUp(restrict=) kwarg
In general, per Liskov, it's not permitted to modify the signature of a function when overriding it. Our MachineCase.setUp() override does this by adding a restrict= parameter. That's strictly OK, since it adds a default value for that argument so there's no situation where a call to .setUp() on the base class would not also work with the overridden method. Unfortunately, it does create a problem further down the line. Since we add this parameter, it means (again, per Liskov) that all of our many subclasses (packagelib, netlib, storagelib, plus individual test cases) need to add it to, and none of them do that. That's hindering our attempt to make this code strictly type-checked with mypy. It looks like this was only ever used from the previous version of cockpit-composer, so let's drop it. If someone else is using this then they can provide the same option via the provision.
1 parent 876349f commit e5516bc

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

test/common/testlib.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,7 @@ def system_before(self, version: int) -> bool:
17371737

17381738
return int(v[0]) < version
17391739

1740-
def setUp(self, restrict: bool = True) -> None:
1740+
def setUp(self) -> None:
17411741
self.allowed_messages = self.default_allowed_messages
17421742
self.allowed_console_errors = self.default_allowed_console_errors
17431743
self.allow_core_dumps = False
@@ -1780,8 +1780,6 @@ def setUp(self, restrict: bool = True) -> None:
17801780
options.pop('address', None)
17811781
options.pop('dns', None)
17821782
options.pop('dhcp', None)
1783-
if 'restrict' not in options:
1784-
options['restrict'] = restrict
17851783
machine = self.new_machine(**options)
17861784
self.machines[key] = machine
17871785
if first_machine:

0 commit comments

Comments
 (0)