Skip to content

Commit 9fe6ad0

Browse files
Fix the test suite for Python 3.12+ and Django 4.2 to 6.1 (#87)
1 parent 1ea9e86 commit 9fe6ad0

7 files changed

Lines changed: 95 additions & 95 deletions

File tree

‎codespeed/__init__.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
default_app_config = 'codespeed.apps.CodespeedConfig'

‎codespeed/commits/tests/test_git.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from datetime import datetime
22
from django.test import TestCase, override_settings
3-
from mock import Mock, patch
3+
from unittest.mock import Mock, patch
44

55
from codespeed.commits.git import getlogs
66
from codespeed.models import Project, Revision, Branch, Environment
@@ -57,4 +57,4 @@ def side_effect(cmd, *args, **kwargs):
5757
'short_commit_id': 'id',
5858
'tag': 'tag',
5959
}
60-
self.assertEquals([expected], logs)
60+
self.assertEqual([expected], logs)

‎codespeed/fixtures/timeline_tests.json‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"commitid": "1",
8383
"tag": "",
8484
"branch": 1,
85-
"date": "2011-04-12T16:43:20",
85+
"date": "2011-04-12T16:43:20Z",
8686
"message": ""
8787
}
8888
},
@@ -95,7 +95,7 @@
9595
"commitid": "2",
9696
"tag": "",
9797
"branch": 1,
98-
"date": "2011-04-13T17:04:22",
98+
"date": "2011-04-13T17:04:22Z",
9999
"message": ""
100100
}
101101
},
@@ -108,7 +108,7 @@
108108
"commitid": "3",
109109
"tag": "",
110110
"branch": 2,
111-
"date": "2011-04-13T12:03:38",
111+
"date": "2011-04-13T12:03:38Z",
112112
"message": ""
113113
}
114114
},
@@ -121,7 +121,7 @@
121121
"commitid": "4",
122122
"tag": "",
123123
"branch": 2,
124-
"date": "2011-04-14T18:04:51",
124+
"date": "2011-04-14T18:04:51Z",
125125
"message": ""
126126
}
127127
},
@@ -134,7 +134,7 @@
134134
"commitid": "5",
135135
"tag": "",
136136
"branch": 1,
137-
"date": "2011-04-14T19:13:05",
137+
"date": "2011-04-14T19:13:05Z",
138138
"message": ""
139139
}
140140
},
@@ -147,7 +147,7 @@
147147
"commitid": "1",
148148
"tag": "",
149149
"branch": 3,
150-
"date": "2011-04-13T12:05:11",
150+
"date": "2011-04-13T12:05:11Z",
151151
"message": ""
152152
}
153153
},
@@ -160,7 +160,7 @@
160160
"commitid": "2",
161161
"tag": "",
162162
"branch": 3,
163-
"date": "2011-04-14T12:05:22",
163+
"date": "2011-04-14T12:05:22Z",
164164
"message": ""
165165
}
166166
},
@@ -173,7 +173,7 @@
173173
"commitid": "444",
174174
"tag": "1.0",
175175
"branch": 4,
176-
"date": "2011-05-24T09:37:32",
176+
"date": "2011-05-24T09:37:32Z",
177177
"message": ""
178178
}
179179
},
@@ -253,7 +253,7 @@
253253
"environment": 1,
254254
"val_min": 3995.1,
255255
"std_dev": 1.11111,
256-
"date": "2011-04-13T19:04:00",
256+
"date": "2011-04-13T19:04:00Z",
257257
"val_max": 4001.6,
258258
"revision": 1
259259
}
@@ -268,7 +268,7 @@
268268
"environment": 1,
269269
"val_min": 1995.1,
270270
"std_dev": 1.11111,
271-
"date": "2011-04-13T17:06:19",
271+
"date": "2011-04-13T17:06:19Z",
272272
"val_max": 2001.6,
273273
"revision": 2
274274
}
@@ -283,7 +283,7 @@
283283
"environment": 1,
284284
"val_min": 995.1,
285285
"std_dev": 1.11111,
286-
"date": "2011-04-13T17:06:47",
286+
"date": "2011-04-13T17:06:47Z",
287287
"val_max": 1001.6,
288288
"revision": 5
289289
}
@@ -298,7 +298,7 @@
298298
"environment": 1,
299299
"val_min": 3995.1,
300300
"std_dev": 1.11111,
301-
"date": "2011-04-13T19:06:11",
301+
"date": "2011-04-13T19:06:11Z",
302302
"val_max": 4001.6,
303303
"revision": 3
304304
}
@@ -313,7 +313,7 @@
313313
"environment": 1,
314314
"val_min": 995.1,
315315
"std_dev": 1.11111,
316-
"date": "2011-04-13T19:11:50",
316+
"date": "2011-04-13T19:11:50Z",
317317
"val_max": 1001.6,
318318
"revision": 6
319319
}
@@ -328,7 +328,7 @@
328328
"environment": 1,
329329
"val_min": 2995.1,
330330
"std_dev": 1.11111,
331-
"date": "2011-04-13T19:06:58",
331+
"date": "2011-04-13T19:06:58Z",
332332
"val_max": 3001.6,
333333
"revision": 4
334334
}
@@ -343,7 +343,7 @@
343343
"environment": 1,
344344
"val_min": 495.1,
345345
"std_dev": 1.11111,
346-
"date": "2011-04-13T19:12:23",
346+
"date": "2011-04-13T19:12:23Z",
347347
"val_max": 501.6,
348348
"revision": 7
349349
}
@@ -358,7 +358,7 @@
358358
"environment": 1,
359359
"val_min": null,
360360
"std_dev": null,
361-
"date": "2011-05-24T09:38:18",
361+
"date": "2011-05-24T09:38:18Z",
362362
"val_max": null,
363363
"revision": 8
364364
}

‎codespeed/results.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
from __future__ import absolute_import
33

44
import logging
5-
from datetime import datetime
65

76
from django.core.exceptions import ValidationError
7+
from django.utils import timezone
88

99
from .models import (Environment, Project, Branch, Benchmark, Executable,
1010
Revision, Result, Report)
@@ -119,7 +119,7 @@ def save_result(data, update_repo=True):
119119
elif rev.date:
120120
r.date = rev.date
121121
else:
122-
r.date = datetime.now()
122+
r.date = timezone.now()
123123

124124
r.std_dev = data.get('std_dev')
125125
r.val_min = data.get('min')

‎codespeed/tests/test_auth.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
import mock
3+
from unittest import mock
44

55
from django.test import TestCase, override_settings
66
from django.http import HttpResponse

‎codespeed/tests/test_models.py‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def test_good_benchmark_change_beats_bad_average_trend(self):
104104
self.make_result(x, rev=s1, benchmark=b1)
105105
self.make_result(changes[-2] * .97, rev=s1, benchmark=b1)
106106
rep = self.make_report(s1)
107-
self.assertEquals('green', rep.colorcode)
107+
self.assertEqual('green', rep.colorcode)
108108
self.assertIn('b1', rep.summary)
109109

110110
def test_good_average_change_beats_bad_average_trend(self):
@@ -116,7 +116,7 @@ def test_good_average_change_beats_bad_average_trend(self):
116116
self.make_result(x, rev=s1, benchmark=b1)
117117
self.make_result(changes[-2] * .92, rev=s1, benchmark=b1)
118118
rep = self.make_report(s1)
119-
self.assertEquals('green', rep.colorcode)
119+
self.assertEqual('green', rep.colorcode)
120120
self.assertIn('Average', rep.summary)
121121

122122
def test_good_change_beats_good_trend(self):
@@ -156,7 +156,7 @@ def test_bad_change_beats_good_trend(self):
156156
rep = self.make_report(s1)
157157
self.assertIn('b1', rep.summary)
158158
self.assertNotIn('trend', rep.summary)
159-
self.assertEquals('red', rep.colorcode)
159+
self.assertEqual('red', rep.colorcode)
160160

161161
def test_bad_beats_good_change(self):
162162
b1 = self.make_bench('b1')
@@ -184,7 +184,7 @@ def test_bigger_bad_beats_smaller_bad(self):
184184

185185
rep = self.make_report(s2)
186186
self.assertIn('b1', rep.summary)
187-
self.assertEquals('red', rep.colorcode)
187+
self.assertEqual('red', rep.colorcode)
188188

189189
def test_multiple_quantities(self):
190190
b1 = self.make_bench('b1', quantity='Space', units='bytes')
@@ -195,8 +195,8 @@ def test_multiple_quantities(self):
195195
self.make_result(1.5, rev=s2, benchmark=b1)
196196

197197
rep = self.make_report(s2)
198-
self.assertRegexpMatches(rep.summary, '[sS]pace')
199-
self.assertEquals('red', rep.colorcode)
198+
self.assertRegex(rep.summary, '[sS]pace')
199+
self.assertEqual('red', rep.colorcode)
200200

201201
def make_result(self, value, rev=None, benchmark=None):
202202
from uuid import uuid4
@@ -280,18 +280,18 @@ def test_github_browsing_url(self):
280280

281281
# It should work with https:// as well as git:// urls
282282
self.github_project.save()
283-
self.assertEquals(self.github_project.commit_browsing_url,
284-
'https://github.com/tobami/codespeed.git/'
285-
'commit/{commitid}')
283+
self.assertEqual(self.github_project.commit_browsing_url,
284+
'https://github.com/tobami/codespeed.git/'
285+
'commit/{commitid}')
286286

287287
self.github_project.repo_path = 'git://github.com/tobami/codespeed.git'
288288
self.github_project.save()
289-
self.assertEquals(self.github_project.commit_browsing_url,
290-
'https://github.com/tobami/codespeed.git/'
291-
'commit/{commitid}')
289+
self.assertEqual(self.github_project.commit_browsing_url,
290+
'https://github.com/tobami/codespeed.git/'
291+
'commit/{commitid}')
292292

293293
# If filled in, commit browsing url should not change
294294
self.github_project.commit_browsing_url = 'https://example.com/{commitid}'
295295
self.github_project.save()
296-
self.assertEquals(self.github_project.commit_browsing_url,
297-
'https://example.com/{commitid}')
296+
self.assertEqual(self.github_project.commit_browsing_url,
297+
'https://example.com/{commitid}')

0 commit comments

Comments
 (0)