当前位置: 首页>>代码示例>>Python>>正文


Python factories.ProblemFactory类代码示例

本文整理汇总了Python中xmodule.tests.xml.factories.ProblemFactory的典型用法代码示例。如果您正苦于以下问题:Python ProblemFactory类的具体用法?Python ProblemFactory怎么用?Python ProblemFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ProblemFactory类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check_inheritable_attribute

    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,代码行数:25,代码来源:test_xml_module.py

示例2: test_inheritable_attribute

    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,代码行数:25,代码来源:test_xml_module.py

示例3: check_inheritable_attribute

    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,代码行数:25,代码来源:test_xml_module.py

示例4: test_rerandomize_in_policy

    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,代码行数:15,代码来源:test_xml_module.py

示例5: test_null_string

    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,代码行数:15,代码来源:test_inheritance.py

示例6: test_attempts_in_policy

    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,代码行数:17,代码来源:test_xml_module.py


注:本文中的xmodule.tests.xml.factories.ProblemFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。