| | 221 | |
| | 222 | try: |
| | 223 | import yaml |
| | 224 | __test__['YAML'] = """ |
| | 225 | # Create some data: |
| | 226 | |
| | 227 | >>> as = Article.objects.all().order_by("id")[:2] |
| | 228 | >>> from django.core import serializers |
| | 229 | |
| | 230 | # test if serial |
| | 231 | |
| | 232 | >>> de = serializers.serialize("yaml", as) |
| | 233 | >>> print de |
| | 234 | - fields: |
| | 235 | author: 2 |
| | 236 | categories: [3, 1] |
| | 237 | headline: Just kidding; I love TV poker |
| | 238 | pub_date: 2006-06-16 11:00:00 |
| | 239 | model: serializers.article |
| | 240 | pk: 1 |
| | 241 | - fields: |
| | 242 | author: 1 |
| | 243 | categories: [2, 3] |
| | 244 | headline: Time to reform copyright |
| | 245 | pub_date: 2006-06-16 13:00:11 |
| | 246 | model: serializers.article |
| | 247 | pk: 2 |
| | 248 | <BLANKLINE> |
| | 249 | |
| | 250 | >>> obs = list(serializers.deserialize("yaml", de)) |
| | 251 | >>> for i in obs: print i |
| | 252 | <DeserializedObject: Just kidding; I love TV poker> |
| | 253 | <DeserializedObject: Time to reform copyright> |
| | 254 | |
| | 255 | """ |
| | 256 | except ImportError: pass |
| | 257 | |