當前位置: 首頁>>代碼示例>>Python>>正文


Python ProblemFactory.build方法代碼示例

本文整理匯總了Python中xmodule.tests.xml.factories.ProblemFactory.build方法的典型用法代碼示例。如果您正苦於以下問題:Python ProblemFactory.build方法的具體用法?Python ProblemFactory.build怎麽用?Python ProblemFactory.build使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在xmodule.tests.xml.factories.ProblemFactory的用法示例。


在下文中一共展示了ProblemFactory.build方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: check_inheritable_attribute

# 需要導入模塊: from xmodule.tests.xml.factories import ProblemFactory [as 別名]
# 或者: from xmodule.tests.xml.factories.ProblemFactory import build [as 別名]
    def check_inheritable_attribute(self, attribute, value):
        # `attribute` isn't a basic attribute of Sequence
        assert_false(hasattr(SequenceDescriptor, attribute))

        # `attribute` is added by InheritanceMixin
        assert_true(hasattr(InheritanceMixin, attribute))

        root = SequenceFactory.build(policy={attribute: str(value)})
        ProblemFactory.build(parent=root)

        # InheritanceMixin will be used when processing the XML
        assert_in(InheritanceMixin, root.xblock_mixins)

        seq = self.process_xml(root)

        assert_equals(seq.unmixed_class, SequenceDescriptor)
        assert_not_equals(type(seq), SequenceDescriptor)

        # `attribute` is added to the constructed sequence, because
        # it's in the InheritanceMixin
        assert_equals(value, getattr(seq, attribute))

        # `attribute` is a known attribute, so we shouldn't include it
        # in xml_attributes
        assert_not_in(attribute, seq.xml_attributes)
開發者ID:bryanlandia,項目名稱:edx-platform,代碼行數:27,代碼來源:test_xml_module.py

示例2: test_inheritable_attribute

# 需要導入模塊: from xmodule.tests.xml.factories import ProblemFactory [as 別名]
# 或者: from xmodule.tests.xml.factories.ProblemFactory import build [as 別名]
    def test_inheritable_attribute(self):
        # days_early_for_beta isn't a basic attribute of Sequence
        assert_false(hasattr(SequenceDescriptor, 'days_early_for_beta'))

        # days_early_for_beta is added by InheritanceMixin
        assert_true(hasattr(InheritanceMixin, 'days_early_for_beta'))

        root = SequenceFactory.build(policy={'days_early_for_beta': '2'})
        ProblemFactory.build(parent=root)

        # InheritanceMixin will be used when processing the XML
        assert_in(InheritanceMixin, root.xblock_mixins)

        seq = self.process_xml(root)

        assert_equals(seq.unmixed_class, SequenceDescriptor)
        assert_not_equals(type(seq), SequenceDescriptor)

        # days_early_for_beta is added to the constructed sequence, because
        # it's in the InheritanceMixin
        assert_equals(2, seq.days_early_for_beta)

        # days_early_for_beta is a known attribute, so we shouldn't include it
        # in xml_attributes
        assert_not_in('days_early_for_beta', seq.xml_attributes)
開發者ID:smartdec,項目名稱:edx-platform,代碼行數:27,代碼來源:test_xml_module.py

示例3: check_inheritable_attribute

# 需要導入模塊: from xmodule.tests.xml.factories import ProblemFactory [as 別名]
# 或者: from xmodule.tests.xml.factories.ProblemFactory import build [as 別名]
    def check_inheritable_attribute(self, attribute, value):
        # `attribute` isn't a basic attribute of Sequence
        assert not hasattr(SequenceDescriptor, attribute)

        # `attribute` is added by InheritanceMixin
        assert hasattr(InheritanceMixin, attribute)

        root = SequenceFactory.build(policy={attribute: str(value)})
        ProblemFactory.build(parent=root)

        # InheritanceMixin will be used when processing the XML
        assert InheritanceMixin in root.xblock_mixins

        seq = self.process_xml(root)

        assert seq.unmixed_class == SequenceDescriptor
        assert type(seq) != SequenceDescriptor

        # `attribute` is added to the constructed sequence, because
        # it's in the InheritanceMixin
        assert getattr(seq, attribute) == value

        # `attribute` is a known attribute, so we shouldn't include it
        # in xml_attributes
        assert attribute not in seq.xml_attributes
開發者ID:digitalsatori,項目名稱:edx-platform,代碼行數:27,代碼來源:test_xml_module.py

示例4: test_rerandomize_in_policy

# 需要導入模塊: from xmodule.tests.xml.factories import ProblemFactory [as 別名]
# 或者: from xmodule.tests.xml.factories.ProblemFactory import build [as 別名]
    def test_rerandomize_in_policy(self):
        # Rerandomize isn't a basic attribute of Sequence
        assert_false(hasattr(SequenceDescriptor, 'rerandomize'))

        root = SequenceFactory.build(policy={'rerandomize': 'never'})
        ProblemFactory.build(parent=root)

        seq = self.process_xml(root)

        # Rerandomize is added to the constructed sequence via the InheritanceMixin
        assert_equals('never', seq.rerandomize)

        # Rerandomize is a known value coming from policy, and shouldn't appear
        # in xml_attributes
        assert_not_in('rerandomize', seq.xml_attributes)
開發者ID:bryanlandia,項目名稱:edx-platform,代碼行數:17,代碼來源:test_xml_module.py

示例5: test_null_string

# 需要導入模塊: from xmodule.tests.xml.factories import ProblemFactory [as 別名]
# 或者: from xmodule.tests.xml.factories.ProblemFactory import build [as 別名]
    def test_null_string(self):
        # Test that the string inherited fields are passed through 'deserialize_field',
        # which converts the string "null" to the python value None
        root = CourseFactory.build(days_early_for_beta="null")
        sequence = SequenceFactory.build(parent=root)
        ProblemFactory.build(parent=sequence)

        course = self.process_xml(root)
        assert_equals(None, course.days_early_for_beta)

        sequence = course.get_children()[0]
        assert_equals(None, sequence.days_early_for_beta)

        problem = sequence.get_children()[0]
        assert_equals(None, problem.days_early_for_beta)
開發者ID:1amongus,項目名稱:edx-platform,代碼行數:17,代碼來源:test_inheritance.py

示例6: test_attempts_in_policy

# 需要導入模塊: from xmodule.tests.xml.factories import ProblemFactory [as 別名]
# 或者: from xmodule.tests.xml.factories.ProblemFactory import build [as 別名]
    def test_attempts_in_policy(self):
        # attempts isn't a basic attribute of Sequence
        assert_false(hasattr(SequenceDescriptor, 'attempts'))

        root = SequenceFactory.build(policy={'attempts': '1'})
        ProblemFactory.build(parent=root)

        seq = self.process_xml(root)

        # attempts isn't added to the constructed sequence, because
        # it's not in the InheritanceMixin
        assert_false(hasattr(seq, 'attempts'))

        # attempts is an unknown attribute, so we should include it
        # in xml_attributes so that it gets written out (despite the misleading
        # name)
        assert_in('attempts', seq.xml_attributes)
開發者ID:bryanlandia,項目名稱:edx-platform,代碼行數:19,代碼來源:test_xml_module.py


注:本文中的xmodule.tests.xml.factories.ProblemFactory.build方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。