Used setUpTestData for the timedelta expression tests.
This commit is contained in:
parent
65aa94200b
commit
31098e3288
|
@ -673,9 +673,10 @@ class ExpressionOperatorTests(TestCase):
|
||||||
|
|
||||||
class FTimeDeltaTests(TestCase):
|
class FTimeDeltaTests(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
self.sday = sday = datetime.date(2010, 6, 25)
|
def setUpTestData(cls):
|
||||||
self.stime = stime = datetime.datetime(2010, 6, 25, 12, 15, 30, 747000)
|
cls.sday = sday = datetime.date(2010, 6, 25)
|
||||||
|
cls.stime = stime = datetime.datetime(2010, 6, 25, 12, 15, 30, 747000)
|
||||||
midnight = datetime.time(0)
|
midnight = datetime.time(0)
|
||||||
|
|
||||||
delta0 = datetime.timedelta(0)
|
delta0 = datetime.timedelta(0)
|
||||||
|
@ -686,18 +687,18 @@ class FTimeDeltaTests(TestCase):
|
||||||
|
|
||||||
# Test data is set so that deltas and delays will be
|
# Test data is set so that deltas and delays will be
|
||||||
# strictly increasing.
|
# strictly increasing.
|
||||||
self.deltas = []
|
cls.deltas = []
|
||||||
self.delays = []
|
cls.delays = []
|
||||||
self.days_long = []
|
cls.days_long = []
|
||||||
|
|
||||||
# e0: started same day as assigned, zero duration
|
# e0: started same day as assigned, zero duration
|
||||||
end = stime + delta0
|
end = stime + delta0
|
||||||
e0 = Experiment.objects.create(name='e0', assigned=sday, start=stime,
|
e0 = Experiment.objects.create(name='e0', assigned=sday, start=stime,
|
||||||
end=end, completed=end.date(), estimated_time=delta0)
|
end=end, completed=end.date(), estimated_time=delta0)
|
||||||
self.deltas.append(delta0)
|
cls.deltas.append(delta0)
|
||||||
self.delays.append(e0.start -
|
cls.delays.append(e0.start -
|
||||||
datetime.datetime.combine(e0.assigned, midnight))
|
datetime.datetime.combine(e0.assigned, midnight))
|
||||||
self.days_long.append(e0.completed - e0.assigned)
|
cls.days_long.append(e0.completed - e0.assigned)
|
||||||
|
|
||||||
# e1: started one day after assigned, tiny duration, data
|
# e1: started one day after assigned, tiny duration, data
|
||||||
# set so that end time has no fractional seconds, which
|
# set so that end time has no fractional seconds, which
|
||||||
|
@ -709,41 +710,41 @@ class FTimeDeltaTests(TestCase):
|
||||||
end = stime + delay + delta1
|
end = stime + delay + delta1
|
||||||
e1 = Experiment.objects.create(name='e1', assigned=sday,
|
e1 = Experiment.objects.create(name='e1', assigned=sday,
|
||||||
start=stime + delay, end=end, completed=end.date(), estimated_time=delta1)
|
start=stime + delay, end=end, completed=end.date(), estimated_time=delta1)
|
||||||
self.deltas.append(delta1)
|
cls.deltas.append(delta1)
|
||||||
self.delays.append(e1.start -
|
cls.delays.append(e1.start -
|
||||||
datetime.datetime.combine(e1.assigned, midnight))
|
datetime.datetime.combine(e1.assigned, midnight))
|
||||||
self.days_long.append(e1.completed - e1.assigned)
|
cls.days_long.append(e1.completed - e1.assigned)
|
||||||
|
|
||||||
# e2: started three days after assigned, small duration
|
# e2: started three days after assigned, small duration
|
||||||
end = stime + delta2
|
end = stime + delta2
|
||||||
e2 = Experiment.objects.create(name='e2',
|
e2 = Experiment.objects.create(name='e2',
|
||||||
assigned=sday - datetime.timedelta(3), start=stime, end=end,
|
assigned=sday - datetime.timedelta(3), start=stime, end=end,
|
||||||
completed=end.date(), estimated_time=datetime.timedelta(hours=1))
|
completed=end.date(), estimated_time=datetime.timedelta(hours=1))
|
||||||
self.deltas.append(delta2)
|
cls.deltas.append(delta2)
|
||||||
self.delays.append(e2.start -
|
cls.delays.append(e2.start -
|
||||||
datetime.datetime.combine(e2.assigned, midnight))
|
datetime.datetime.combine(e2.assigned, midnight))
|
||||||
self.days_long.append(e2.completed - e2.assigned)
|
cls.days_long.append(e2.completed - e2.assigned)
|
||||||
|
|
||||||
# e3: started four days after assigned, medium duration
|
# e3: started four days after assigned, medium duration
|
||||||
delay = datetime.timedelta(4)
|
delay = datetime.timedelta(4)
|
||||||
end = stime + delay + delta3
|
end = stime + delay + delta3
|
||||||
e3 = Experiment.objects.create(name='e3',
|
e3 = Experiment.objects.create(name='e3',
|
||||||
assigned=sday, start=stime + delay, end=end, completed=end.date(), estimated_time=delta3)
|
assigned=sday, start=stime + delay, end=end, completed=end.date(), estimated_time=delta3)
|
||||||
self.deltas.append(delta3)
|
cls.deltas.append(delta3)
|
||||||
self.delays.append(e3.start -
|
cls.delays.append(e3.start -
|
||||||
datetime.datetime.combine(e3.assigned, midnight))
|
datetime.datetime.combine(e3.assigned, midnight))
|
||||||
self.days_long.append(e3.completed - e3.assigned)
|
cls.days_long.append(e3.completed - e3.assigned)
|
||||||
|
|
||||||
# e4: started 10 days after assignment, long duration
|
# e4: started 10 days after assignment, long duration
|
||||||
end = stime + delta4
|
end = stime + delta4
|
||||||
e4 = Experiment.objects.create(name='e4',
|
e4 = Experiment.objects.create(name='e4',
|
||||||
assigned=sday - datetime.timedelta(10), start=stime, end=end,
|
assigned=sday - datetime.timedelta(10), start=stime, end=end,
|
||||||
completed=end.date(), estimated_time=delta4 - datetime.timedelta(1))
|
completed=end.date(), estimated_time=delta4 - datetime.timedelta(1))
|
||||||
self.deltas.append(delta4)
|
cls.deltas.append(delta4)
|
||||||
self.delays.append(e4.start -
|
cls.delays.append(e4.start -
|
||||||
datetime.datetime.combine(e4.assigned, midnight))
|
datetime.datetime.combine(e4.assigned, midnight))
|
||||||
self.days_long.append(e4.completed - e4.assigned)
|
cls.days_long.append(e4.completed - e4.assigned)
|
||||||
self.expnames = [e.name for e in Experiment.objects.all()]
|
cls.expnames = [e.name for e in Experiment.objects.all()]
|
||||||
|
|
||||||
def test_multiple_query_compilation(self):
|
def test_multiple_query_compilation(self):
|
||||||
# Ticket #21643
|
# Ticket #21643
|
||||||
|
|
Loading…
Reference in New Issue