mirror of
https://github.com/django/django.git
synced 2025-10-25 06:36:07 +00:00
Properly skipped yaml tests when not installed
This commit is contained in:
@@ -5,6 +5,12 @@ import json
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import unittest
|
import unittest
|
||||||
from xml.dom import minidom
|
from xml.dom import minidom
|
||||||
|
try:
|
||||||
|
import yaml
|
||||||
|
HAS_YAML = True
|
||||||
|
except ImportError:
|
||||||
|
HAS_YAML = False
|
||||||
|
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core import serializers
|
from django.core import serializers
|
||||||
@@ -445,11 +451,8 @@ class JsonSerializerTransactionTestCase(SerializersTransactionTestBase, Transact
|
|||||||
}
|
}
|
||||||
}]"""
|
}]"""
|
||||||
|
|
||||||
try:
|
|
||||||
import yaml
|
@unittest.skipUnless(HAS_YAML, "No yaml library detected")
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
class YamlSerializerTestCase(SerializersTestBase, TestCase):
|
class YamlSerializerTestCase(SerializersTestBase, TestCase):
|
||||||
serializer_name = "yaml"
|
serializer_name = "yaml"
|
||||||
fwd_ref_str = """- fields:
|
fwd_ref_str = """- fields:
|
||||||
@@ -509,6 +512,8 @@ else:
|
|||||||
ret_list.append(str(field_value))
|
ret_list.append(str(field_value))
|
||||||
return ret_list
|
return ret_list
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipUnless(HAS_YAML, "No yaml library detected")
|
||||||
class YamlSerializerTransactionTestCase(SerializersTransactionTestBase, TransactionTestCase):
|
class YamlSerializerTransactionTestCase(SerializersTransactionTestBase, TransactionTestCase):
|
||||||
serializer_name = "yaml"
|
serializer_name = "yaml"
|
||||||
fwd_ref_str = """- fields:
|
fwd_ref_str = """- fields:
|
||||||
|
|||||||
Reference in New Issue
Block a user