mirror of https://github.com/django/django.git
Properly skipped yaml tests when not installed
This commit is contained in:
parent
3e34005b1b
commit
e0643cb676
|
@ -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,12 +451,9 @@ class JsonSerializerTransactionTestCase(SerializersTransactionTestBase, Transact
|
||||||
}
|
}
|
||||||
}]"""
|
}]"""
|
||||||
|
|
||||||
try:
|
|
||||||
import yaml
|
@unittest.skipUnless(HAS_YAML, "No yaml library detected")
|
||||||
except ImportError:
|
class YamlSerializerTestCase(SerializersTestBase, TestCase):
|
||||||
pass
|
|
||||||
else:
|
|
||||||
class YamlSerializerTestCase(SerializersTestBase, TestCase):
|
|
||||||
serializer_name = "yaml"
|
serializer_name = "yaml"
|
||||||
fwd_ref_str = """- fields:
|
fwd_ref_str = """- fields:
|
||||||
headline: Forward references pose no problem
|
headline: Forward references pose no problem
|
||||||
|
@ -509,7 +512,9 @@ else:
|
||||||
ret_list.append(str(field_value))
|
ret_list.append(str(field_value))
|
||||||
return ret_list
|
return ret_list
|
||||||
|
|
||||||
class YamlSerializerTransactionTestCase(SerializersTransactionTestBase, TransactionTestCase):
|
|
||||||
|
@unittest.skipUnless(HAS_YAML, "No yaml library detected")
|
||||||
|
class YamlSerializerTransactionTestCase(SerializersTransactionTestBase, TransactionTestCase):
|
||||||
serializer_name = "yaml"
|
serializer_name = "yaml"
|
||||||
fwd_ref_str = """- fields:
|
fwd_ref_str = """- fields:
|
||||||
headline: Forward references pose no problem
|
headline: Forward references pose no problem
|
||||||
|
|
Loading…
Reference in New Issue