Skip to content

Commit

Permalink
Upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
Mogost committed Jun 12, 2024
1 parent 448a91a commit 35c8580
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion post_office/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from ast import literal_eval
from os.path import dirname, join

with open(join(dirname(__file__), 'version.txt'), 'r') as fh:
with open(join(dirname(__file__), 'version.txt')) as fh:
VERSION = literal_eval(fh.read())

from .backends import EmailBackend
Expand Down
2 changes: 1 addition & 1 deletion post_office/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


def get_message_preview(instance):
return ('{0}...'.format(instance.message[:25]) if len(instance.message) > 25
return (f'{instance.message[:25]}...' if len(instance.message) > 25
else instance.message)


Expand Down
2 changes: 1 addition & 1 deletion post_office/lockfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, lock_filename, timeout=None, force=False):
def get_lock_pid(self):
try:
return int(open(self.lock_filename).read())
except IOError:
except OSError:
# If we can't read symbolic link, there are two possibilities:
# 1. The symbolic link is dead (point to non existing file)
# 2. Symbolic link is not there
Expand Down
2 changes: 1 addition & 1 deletion post_office/migrations/0002_add_i18n_and_backend_alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ class Migration(migrations.Migration):
),
migrations.AlterUniqueTogether(
name='emailtemplate',
unique_together=set([('language', 'default_template')]),
unique_together={('language', 'default_template')},
),
]
2 changes: 1 addition & 1 deletion post_office/migrations/0005_auto_20170515_0013.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ class Migration(migrations.Migration):
operations = [
migrations.AlterUniqueTogether(
name='emailtemplate',
unique_together=set([('name', 'language', 'default_template')]),
unique_together={('name', 'language', 'default_template')},
),
]
2 changes: 1 addition & 1 deletion post_office/migrations/0010_message_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def forwards(apps, schema_editor):
if email.status in [STATUS.queued, STATUS.requeued]:
# create a unique Message-ID for all emails which have not been send yet
randint1, randint2 = random.getrandbits(64), random.getrandbits(16)
email.message_id = '<{}.{}.{}@{}>'.format(email.id, randint1, randint2, msg_id_fqdn)
email.message_id = f'<{email.id}.{randint1}.{randint2}@{msg_id_fqdn}>'
email.save()


Expand Down
6 changes: 3 additions & 3 deletions post_office/templatetags/post_office.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def inline_image(context, file):
try:
absfilename = finders.find(file)
if absfilename is None:
raise FileNotFoundError("No such file: {}".format(file))
raise FileNotFoundError(f"No such file: {file}")
except Exception:
if settings.DEBUG:
raise
Expand All @@ -33,6 +33,6 @@ def inline_image(context, file):
image = MIMEImage(raw_data)
md5sum = hashlib.md5(raw_data).hexdigest()
image.add_header('Content-Disposition', 'inline', filename=md5sum)
image.add_header('Content-ID', '<{}>'.format(md5sum))
image.add_header('Content-ID', f'<{md5sum}>')
context.template._attached_images.append(image)
return 'cid:{}'.format(md5sum)
return f'cid:{md5sum}'
2 changes: 1 addition & 1 deletion post_office/tests/test_html_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test_email_change_view(self):
try:
import bleach
self.assertContains(response, "<h3>Testing image attachments</h3>")
self.assertContains(response, '<img src="{}" width="200"'.format(email_image_url))
self.assertContains(response, f'<img src="{email_image_url}" width="200"')
except ImportError:
self.assertContains(response, "Testing image attachments")

Expand Down
10 changes: 5 additions & 5 deletions post_office/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def test_create_attachments(self):
self.assertTrue(attachments[0].pk)
self.assertEqual(attachments[0].file.read(), b'content')
self.assertTrue(attachments[0].name.startswith('attachment_file'))
self.assertEquals(attachments[0].mimetype, '')
self.assertEqual(attachments[0].mimetype, '')

def test_create_attachments_with_mimetype(self):
attachments = create_attachments({
Expand All @@ -161,9 +161,9 @@ def test_create_attachments_with_mimetype(self):
self.assertEqual(len(attachments), 2)
self.assertIsInstance(attachments[0], Attachment)
self.assertTrue(attachments[0].pk)
self.assertEquals(attachments[0].file.read(), b'content')
self.assertEqual(attachments[0].file.read(), b'content')
self.assertTrue(attachments[0].name.startswith('attachment_file'))
self.assertEquals(attachments[0].mimetype, 'text/plain')
self.assertEqual(attachments[0].mimetype, 'text/plain')

def test_create_attachments_open_file(self):
attachments = create_attachments({
Expand All @@ -174,8 +174,8 @@ def test_create_attachments_open_file(self):
self.assertIsInstance(attachments[0], Attachment)
self.assertTrue(attachments[0].pk)
self.assertTrue(attachments[0].file.read())
self.assertEquals(attachments[0].name, 'attachment_file.py')
self.assertEquals(attachments[0].mimetype, '')
self.assertEqual(attachments[0].name, 'attachment_file.py')
self.assertEqual(attachments[0].mimetype, '')

def test_parse_priority(self):
self.assertEqual(parse_priority('now'), PRIORITY.now)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def run_tests(self):
sys.exit(errno)


with open(join(dirname(__file__), 'post_office/version.txt'), 'r') as fh:
with open(join(dirname(__file__), 'post_office/version.txt')) as fh:
VERSION = '.'.join(map(str, literal_eval(fh.read())))

TESTS_REQUIRE = ['tox >= 2.3']
Expand Down

0 comments on commit 35c8580

Please sign in to comment.