Skip to content

Commit

Permalink
fix compat
Browse files Browse the repository at this point in the history
  • Loading branch information
nitely committed Mar 3, 2020
1 parent 64510f6 commit 8e199e0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 4 additions & 3 deletions spirit/comment/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,10 @@ def test_comment_image_upload_unique_no_name(self):
HTTP_X_REQUESTED_WITH='XMLHttpRequest',
data={'image': file})
res = json.loads(response.content.decode('utf-8'))
self.assertIn(
'File extension “” is not allowed',
res['error']['image'][0])
# django 2.2 and 3.0 compat
self.assertTrue(
'File extension “” is not allowed' in res['error']['image'][0]
or 'File extension \'\' is not allowed' in res['error']['image'][0])

@override_settings(MEDIA_ROOT=os.path.join(settings.BASE_DIR, 'media_test'))
def test_comment_image_upload_unique_bad_name(self):
Expand Down
10 changes: 8 additions & 2 deletions spirit/core/tests/tests_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ def render(date):
self.assertEqual(render(now - datetime.timedelta(minutes=1)), "1m")
self.assertEqual(render(now - datetime.timedelta(hours=1)), "1h")
self.assertEqual(render(now - datetime.timedelta(days=1)), "8 Mar")
self.assertEqual(render(now - datetime.timedelta(days=69)), "31 Dec '11")
# django 2.2 and 3.0 compat
self.assertTrue(
render(now - datetime.timedelta(days=69)) == "31 Dec '11"
or render(now - datetime.timedelta(days=69)) == "31 Dec '11")

# Tests it uses localtime
# This is 2012-03-08HT19:30:00-06:00 in America/Chicago
Expand All @@ -171,7 +174,10 @@ def render(date):
timezone.deactivate()

with override_settings(TIME_ZONE="America/Chicago"):
self.assertEqual(render(dt), "8 Mar '11")
# django 2.2 and 3.0 compat
self.assertTrue(
render(dt) == "8 Mar '11"
or render(dt) == "8 Mar '11")
finally:
ttags_utils.datetime = orig_humanize_datetime

Expand Down

0 comments on commit 8e199e0

Please sign in to comment.