Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix default value for additional param #2553

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions test/testpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,19 @@

class SimpleTestCase(test.TestCase):

def __init__(self, path, file, arch, mode, context, config, additional=[]):
def __init__(self, path, file, arch, mode, context, config, additional=None):
super(SimpleTestCase, self).__init__(context, path, arch, mode)
self.file = file
self.config = config
self.arch = arch
self.mode = mode
self.tmpdir = join(dirname(self.config.root), 'tmp')
self.additional_flags = additional
if additional is not None:
self.additional_flags = additional
else:
self.additional_flags = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could shorten this to self.additional_flags = additional or [].

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bnoordhuis Correct but if an empty list is actually passed, we ll still ignore it and create a new list, if we do additional or [] . We don't want that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bnoordhuis ping!




def GetLabel(self):
return "%s %s" % (self.mode, self.GetName())

Expand Down Expand Up @@ -81,10 +84,13 @@ def GetSource(self):

class SimpleTestConfiguration(test.TestConfiguration):

def __init__(self, context, root, section, additional=[]):
def __init__(self, context, root, section, additional=None):
super(SimpleTestConfiguration, self).__init__(context, root)
self.section = section
self.additional_flags = additional
if additional is not None:
self.additional_flags = additional
else:
self.additional_flags = []

def Ls(self, path):
def SelectTest(name):
Expand All @@ -110,7 +116,7 @@ def GetTestStatus(self, sections, defs):
test.ReadConfigurationInto(status_file, sections, defs)

class ParallelTestConfiguration(SimpleTestConfiguration):
def __init__(self, context, root, section, additional=[]):
def __init__(self, context, root, section, additional=None):
super(ParallelTestConfiguration, self).__init__(context, root, section,
additional)

Expand All @@ -122,7 +128,7 @@ def ListTests(self, current_path, path, arch, mode):
return result

class AddonTestConfiguration(SimpleTestConfiguration):
def __init__(self, context, root, section, additional=[]):
def __init__(self, context, root, section, additional=None):
super(AddonTestConfiguration, self).__init__(context, root, section)

def Ls(self, path):
Expand Down