fix: fix 'no-member' for pylint
This commit is contained in:
parent
87af670df6
commit
79bab4f9e1
3 changed files with 16 additions and 16 deletions
|
@ -22,6 +22,7 @@ enable=anomalous-backslash-in-string,
|
|||
missing-module-docstring,
|
||||
no-else-return,
|
||||
no-self-argument,
|
||||
no-member,
|
||||
possibly-used-before-assignment,
|
||||
redefined-argument-from-local,
|
||||
redefined-outer-name,
|
||||
|
|
|
@ -187,15 +187,15 @@ class Message:
|
|||
self.key = key
|
||||
self.sender = sender
|
||||
self.subject = subject
|
||||
self.set_recips('to', to)
|
||||
self.set_recips('cc', cc)
|
||||
self.set_recips('bcc', bcc)
|
||||
self.to = self.get_recips(to)
|
||||
self.cc = self.get_recips(cc)
|
||||
self.bcc = self.get_recips(bcc)
|
||||
self.replyto = replyto
|
||||
self.txt_body = txt_body
|
||||
self.html_body = html_body
|
||||
self.attachments = attachments or []
|
||||
|
||||
def set_recips(self, name, value): # pylint: disable=empty-docstring
|
||||
def get_recips(self, value): # pylint: disable=empty-docstring
|
||||
""" """
|
||||
if value:
|
||||
if isinstance(value, str):
|
||||
|
@ -204,7 +204,7 @@ class Message:
|
|||
raise ValueError("must specify a string, tuple or list value")
|
||||
else:
|
||||
value = []
|
||||
setattr(self, name, list(value))
|
||||
return list(value)
|
||||
|
||||
def as_string(self):
|
||||
"""
|
||||
|
|
|
@ -30,28 +30,27 @@ class TestMessage(FileTestCase):
|
|||
def make_message(self, **kwargs):
|
||||
return mod.Message(**kwargs)
|
||||
|
||||
def test_set_recips(self):
|
||||
def test_get_recips(self):
|
||||
msg = self.make_message()
|
||||
self.assertEqual(msg.to, [])
|
||||
|
||||
# set as list
|
||||
msg.set_recips('to', ['sally@example.com'])
|
||||
self.assertEqual(msg.to, ['sally@example.com'])
|
||||
recips = msg.get_recips(['sally@example.com'])
|
||||
self.assertEqual(recips, ['sally@example.com'])
|
||||
|
||||
# set as tuple
|
||||
msg.set_recips('to', ('barney@example.com',))
|
||||
self.assertEqual(msg.to, ['barney@example.com'])
|
||||
recips = msg.get_recips(('barney@example.com',))
|
||||
self.assertEqual(recips, ['barney@example.com'])
|
||||
|
||||
# set as string
|
||||
msg.set_recips('to', 'wilma@example.com')
|
||||
self.assertEqual(msg.to, ['wilma@example.com'])
|
||||
recips = msg.get_recips('wilma@example.com')
|
||||
self.assertEqual(recips, ['wilma@example.com'])
|
||||
|
||||
# set as null
|
||||
msg.set_recips('to', None)
|
||||
self.assertEqual(msg.to, [])
|
||||
recips = msg.get_recips(None)
|
||||
self.assertEqual(recips, [])
|
||||
|
||||
# otherwise error
|
||||
self.assertRaises(ValueError, msg.set_recips, 'to', {'foo': 'foo@example.com'})
|
||||
self.assertRaises(ValueError, msg.get_recips, {'foo': 'foo@example.com'})
|
||||
|
||||
def test_as_string(self):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue