Ticket #7136: shell_results.py

File shell_results.py, 4.6 KB (added by socrates, 16 years ago)

This file is to easily reproduce the shell results and see the situation before and after the patch

Line 
1#
2# The code to generate the shell results.
3#
4
5from modeltests.model_inheritance.models import *
6Vehicle.objects.all().delete()
7Boat(name="dingy", has_sail=False).save()
8dingy_vehicle = Vehicle.objects.get(name="dingy")
9dingy_vehicle.car
10dingy_vehicle.boat
11dingy_vehicle.car
12dingy_vehicle.boat
13Car(name="my rolls", wheels=4).save()
14rolls_vehicle = Vehicle.objects.get(name="my rolls")
15rolls_vehicle.car
16rolls_vehicle.boat
17rolls_vehicle.car
18rolls_vehicle.boat
19amphibian = Amphibian()
20amphibian.name = "optimus prime"
21amphibian.has_sail = True
22amphibian.wheels = 23
23amphibian.is_a_robot_in_disguise = True
24amphibian.save()
25robot_vehicle = Vehicle.objects.get(name="optimus prime")
26robot_vehicle.car
27robot_vehicle.boat
28robot_vehicle.car
29robot_vehicle.boat
30robot_vehicle.car.amphibian
31robot_vehicle.boat.amphibian
32
33#
34# Shell results before the code was changed
35#
36
37>>> from modeltests.model_inheritance.models import *
38>>> Vehicle.objects.all().delete()
39>>> Boat(name="dingy", has_sail=False).save()
40>>> dingy_vehicle = Vehicle.objects.get(name="dingy")
41>>> dingy_vehicle.car
42Traceback (most recent call last):
43 ...
44DoesNotExist: Car matching query does not exist.
45>>> dingy_vehicle.boat
46<Boat: A boat called dingy without a sail>
47>>> dingy_vehicle.car # should get error
48<Boat: A boat called dingy without a sail>
49>>> dingy_vehicle.boat
50<Boat: A boat called dingy without a sail>
51>>> Car(name="my rolls", wheels=4).save()
52>>> rolls_vehicle = Vehicle.objects.get(name="my rolls")
53>>> rolls_vehicle.car
54<Car: A car called my rolls with 4 wheels>
55>>> rolls_vehicle.boat # should get error
56<Car: A car called my rolls with 4 wheels>
57>>> rolls_vehicle.car
58<Car: A car called my rolls with 4 wheels>
59>>> rolls_vehicle.boat # should get error
60<Car: A car called my rolls with 4 wheels>
61>>> amphibian = Amphibian()
62>>> amphibian.name = "optimus prime"
63>>> amphibian.has_sail = True
64>>> amphibian.wheels = 23
65>>> amphibian.is_a_robot_in_disguise = True
66>>> amphibian.save()
67>>> robot_vehicle = Vehicle.objects.get(name="optimus prime")
68>>> robot_vehicle.car
69<Car: A car called optimus prime with 23 wheels>
70>>> robot_vehicle.boat # wrong object we want to see the boat part of optimus prime
71<Car: A car called optimus prime with 23 wheels>
72>>> robot_vehicle.car
73<Car: A car called optimus prime with 23 wheels>
74>>> robot_vehicle.boat # wrong object we want to see the boat part of optimus prime
75<Car: A car called optimus prime with 23 wheels>
76>>> robot_vehicle.car.amphibian
77<Amphibian: An ampibian which is 1) A car called optimus prime with 23 wheels and 2) A boat called optimus prime with a sail>
78>>> robot_vehicle.boat.amphibian
79<Amphibian: An ampibian which is 1) A car called optimus prime with 23 wheels and 2) A boat called optimus prime with a sail>
80
81#
82# Shell results after the code was changed
83#
84
85>>> from modeltests.model_inheritance.models import *
86>>> Vehicle.objects.all().delete()
87>>> Boat(name="dingy", has_sail=False).save()
88>>> dingy_vehicle = Vehicle.objects.get(name="dingy")
89>>> dingy_vehicle.car # the dingy is not a car
90Traceback (most recent call last):
91 ...
92DoesNotExist: Car matching query does not exist.
93>>> dingy_vehicle.boat
94<Boat: A boat called dingy without a sail>
95>>> dingy_vehicle.car # the dingy is still not a car
96Traceback (most recent call last):
97 ...
98DoesNotExist: Car matching query does not exist.
99>>> dingy_vehicle.boat
100<Boat: A boat called dingy without a sail>
101>>> Car(name="my rolls", wheels=4).save()
102>>> rolls_vehicle = Vehicle.objects.get(name="my rolls")
103>>> rolls_vehicle.car
104<Car: A car called my rolls with 4 wheels>
105>>> rolls_vehicle.boat
106Traceback (most recent call last):
107 ...
108DoesNotExist: Boat matching query does not exist.
109>>> rolls_vehicle.car
110<Car: A car called my rolls with 4 wheels>
111>>> rolls_vehicle.boat
112Traceback (most recent call last):
113 ...
114DoesNotExist: Boat matching query does not exist.
115>>> amphibian = Amphibian()
116>>> amphibian.name = "optimus prime"
117>>> amphibian.has_sail = True
118>>> amphibian.wheels = 23
119>>> amphibian.is_a_robot_in_disguise = True
120>>> amphibian.save()
121>>> robot_vehicle = Vehicle.objects.get(name="optimus prime")
122>>> robot_vehicle.car
123<Car: A car called optimus prime with 23 wheels>
124>>> robot_vehicle.boat
125<Boat: A boat called optimus prime with a sail>
126>>> robot_vehicle.car
127<Car: A car called optimus prime with 23 wheels>
128>>> robot_vehicle.boat
129<Boat: A boat called optimus prime with a sail>
130>>> robot_vehicle.car.amphibian
131<Amphibian: An ampibian which is 1) A car called optimus prime with 23 wheels and 2) A boat called optimus prime with a sail>
132>>> robot_vehicle.boat.amphibian
133<Amphibian: An ampibian which is 1) A car called optimus prime with 23 wheels and 2) A boat called optimus prime with a sail>
Back to Top