• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python io.import_from_yaml函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_examples

 def test_examples(self):
     files = ['elevator', 'elevator_contract', 'microwave', 'tester_elevator_7th_floor_never_reached',
              'tester_elevator_moves_after_10s', 'writer_options']
     for f in files:
         d = io.export_to_yaml(io.import_from_yaml(open(os.path.join('docs', 'examples', f+'.yaml'))))
         # check
         io.import_from_yaml(d)
开发者ID:tommens,项目名称:sismic,代码行数:7,代码来源:test_io.py


示例2: test_examples

 def test_examples(self):
     files = ['elevator', 'elevator_contract', 'microwave', 'tester_elevator_7th_floor_never_reached',
              'tester_elevator_moves_after_10s', 'writer_options']
     for filename in files:
         with self.subTest(filename=filename):
             with open(os.path.join('docs', 'examples', filename + '.yaml')) as f:
                 io.import_from_yaml(f)
开发者ID:EdwardBetts,项目名称:sismic,代码行数:7,代码来源:test_io.py


示例3: test_yaml_tests

 def test_yaml_tests(self):
     files = ['actions', 'composite', 'deep_history', 'infinite', 'internal', 'nested_parallel',
              'nondeterministic', 'parallel', 'simple', 'timer']
     for filename in files:
         with self.subTest(filename=filename):
             with open(os.path.join('tests', 'yaml', filename + '.yaml')) as f:
                 io.import_from_yaml(f)
开发者ID:EdwardBetts,项目名称:sismic,代码行数:7,代码来源:test_io.py


示例4: test_yaml_tests

 def test_yaml_tests(self):
     files = ['actions', 'composite', 'deep_history', 'infinite', 'internal', 'nested_parallel',
              'nondeterministic', 'parallel', 'simple', 'timer']
     for f in files:
         d = io.export_to_yaml(io.import_from_yaml(open(os.path.join('tests', 'yaml', f+'.yaml'))))
         # check
         io.import_from_yaml(d)
开发者ID:tommens,项目名称:sismic,代码行数:7,代码来源:test_io.py


示例5: test_export_valid

    def test_export_valid(self):
        for f, filename in self.files:
            with self.subTest(filename=filename):
                sc_1 = io.import_from_yaml(f)
                ex_1 = io.export_to_yaml(sc_1)
                sc_2 = io.import_from_yaml(ex_1)

                self.assertTrue(sc_2.validate())
开发者ID:EdwardBetts,项目名称:sismic,代码行数:8,代码来源:test_io.py


示例6: setUp

    def setUp(self):
        with open('tests/yaml/simple.yaml') as f:
            self.sc1 = io.import_from_yaml(f)
        with open('tests/yaml/composite.yaml') as f:
            self.sc2 = io.import_from_yaml(f)

        for state in self.sc1.states:
            self.sc1.rename_state(state, 'sc1_' + state)
开发者ID:AlexandreDecan,项目名称:sismic,代码行数:8,代码来源:test_model.py


示例7: test_7th_floor_never_reached_fails

    def test_7th_floor_never_reached_fails(self):
        tested = Interpreter(io.import_from_yaml(open('docs/examples/elevator.yaml')))
        story = Story([Event('floorSelected', floor=4), Pause(2), Event('floorSelected', floor=7)])
        trace = story.tell(tested).trace

        test_story = teststory_from_trace(trace)

        tester = Interpreter(io.import_from_yaml(open('docs/examples/tester_elevator_7th_floor_never_reached.yaml')))
        self.assertFalse(test_story.tell(tester).final)
开发者ID:tommens,项目名称:sismic,代码行数:9,代码来源:test_testing.py


示例8: setUp

    def setUp(self):
        with open('docs/examples/elevator.yaml') as f:
            elevator = io.import_from_yaml(f)
        with open('docs/examples/elevator_buttons.yaml') as f:
            buttons = io.import_from_yaml(f)

        self.elevator = Interpreter(elevator)
        self.buttons = Interpreter(buttons)
        self.buttons.bind(self.elevator)
开发者ID:mgoeminne,项目名称:sismic,代码行数:9,代码来源:test_examples.py


示例9: test_remove_nested_states

    def test_remove_nested_states(self):
        with open('tests/yaml/composite.yaml') as f:
            self.sc = io.import_from_yaml(f)
        self.sc.remove_state('s1')
        self.assertFalse('s1a' in self.sc.states)
        self.sc.validate()

        with open('tests/yaml/composite.yaml') as f:
            self.sc = io.import_from_yaml(f)
        self.sc.remove_state('s1a')
        self.assertFalse('s1a' in self.sc.states)
        self.sc.validate()
开发者ID:AlexandreDecan,项目名称:sismic,代码行数:12,代码来源:test_model.py


示例10: test_transitions_to_unknown_state

 def test_transitions_to_unknown_state(self):
     yaml = """
     statechart:
       name: test
       root state:
         name: root
         initial: s1
         states:
           - name: s1
             transitions:
               - target: s2
     """
     with self.assertRaises(exceptions.StatechartError) as cm:
         io.import_from_yaml(yaml)
     self.assertIn('Unknown target state', str(cm.exception))
开发者ID:EdwardBetts,项目名称:sismic,代码行数:15,代码来源:test_io.py


示例11: setUp

 def setUp(self):
     with open('tests/yaml/nested_parallel.yaml') as f:
         sc = io.import_from_yaml(f)
     self.interpreter = Interpreter(sc)
     # Stabilization
     self.interpreter.execute_once()
     self.common_states = ['root', 's1', 'p1', 'p2', 'r1', 'r2', 'r3', 'r4']
开发者ID:AlexandreDecan,项目名称:sismic,代码行数:7,代码来源:test_interpreter.py


示例12: test_simple

    def test_simple(self):
        with open('tests/yaml/simple.yaml') as f:
            sc = io.import_from_yaml(f)
        interpreter = Interpreter(sc)

        trace = Story([Pause(2), Event('goto s2'), Pause(3)]).tell(interpreter)
        story = teststory_from_trace(trace)

        expected = Story([
            Event('execution started'),
            Pause(2),
            Event('step started'),
            Event('state entered', state='root'),
            Event('state entered', state='s1'),
            Event('step ended'),
            Event('step started'),
            Event('event consumed', event=Event('goto s2')),
            Event('state exited', state='s1'),
            Event('transition processed', source='s1', target='s2', event=Event('goto s2')),
            Event('state entered', state='s2'),
            Event('step ended'),
            Event('step started'),
            Event('state exited', state='s2'),
            Event('transition processed', source='s2', target='s3', event=None),
            Event('state entered', state='s3'),
            Event('step ended'),
            Event('execution stopped')
        ])
        for a, b in zip(story, expected):
            self.assertEqual(a, b)
            if isinstance(a, Event):
                self.assertEqual(a.data.items(), b.data.items())
            else:
                self.assertEqual(a.duration, b.duration)
开发者ID:AlexandreDecan,项目名称:sismic,代码行数:34,代码来源:test_testing.py


示例13: test_order_constraints

    def test_order_constraints(self):
        """
        test if the adding order of the constraints influences the coordinates of the statechart.
        """
        with open("tests/elevator.yaml", 'r') as stream:
            statechart = io.import_from_yaml(stream)
            assert isinstance(statechart, sismic.model.Statechart)
        root_box = RootBox(statechart)
        root_box.add_constraint(
            Constraint(root_box.get_box_by_name('doorsClosed'), 'south', root_box.get_box_by_name('doorsOpen')))
        root_box.add_constraint(
            Constraint(root_box.get_box_by_name('doorsClosed'), 'west', root_box.get_box_by_name('moving')))
        root_box.transitions
        coordinates1 = root_box.coordinates
        set1 = root_box.constraints.copy()

        root_box.add_constraint(
            Constraint(root_box.get_box_by_name('doorsClosed'), 'north', root_box.get_box_by_name('doorsOpen')))
        root_box.add_constraint(
            Constraint(root_box.get_box_by_name('doorsClosed'), 'east', root_box.get_box_by_name('moving')))
        root_box.add_constraint(
            Constraint(root_box.get_box_by_name('doorsClosed'), 'west', root_box.get_box_by_name('moving')))
        root_box.add_constraint(
            Constraint(root_box.get_box_by_name('doorsClosed'), 'south', root_box.get_box_by_name('doorsOpen')))
        root_box.transitions
        coordinates2 = root_box.coordinates
        set2 = root_box.constraints.copy()

        self.assertEqual(set1, set2)
        for key in coordinates1.keys():
            self.assertEqual(coordinates1[key], coordinates2[key],
                             msg='the positions of ' + str(key) + ' are not equals')
开发者ID:radioGiorgio,项目名称:statechart-visualizer,代码行数:32,代码来源:unit_tests.py


示例14: setUp

    def setUp(self):
        self.sc = import_from_yaml("""
        statechart:
          name: test contract
          root state:
            name: root
            on entry: x = 1
            initial: s0
            states:
             - name: s0
               initial: s1
               transitions:
               - event: end
                 target: root
               states:
               - name: s1
                 transitions:
                   - target: s2
                     action: x = 2
                     event: e
               - name: s2
        """)

        self.root = self.sc.state_for('root')  # Will never be exited
        self.s0 = self.sc.state_for('s0')  # Will be exited on "end"
        self.s1 = self.sc.state_for('s1')  # Entered, and then exited on e.
        self.s2 = self.sc.state_for('s2')  # Entered when e
        self.intp = Interpreter(self.sc)
开发者ID:AlexandreDecan,项目名称:sismic,代码行数:28,代码来源:test_evaluator.py


示例15: test_declare_both_states_and_parallel_states

    def test_declare_both_states_and_parallel_states(self):
        yaml = """
        statechart:
          name: test
          root state:
            name: root
            initial: s1
            states:
              - name: s1
            parallel states:
              - name: s2
        """

        with self.assertRaises(exceptions.StatechartError) as cm:
            io.import_from_yaml(yaml)
        self.assertIn('root cannot declare both a "states" and a "parallel states" property', str(cm.exception))
开发者ID:EdwardBetts,项目名称:sismic,代码行数:16,代码来源:test_io.py


示例16: test_move_with_memory

 def test_move_with_memory(self):
     with open('tests/yaml/history.yaml') as f:
         self.sc = io.import_from_yaml(f)
     self.sc.state_for('loop.H').memory = 's1'
     self.sc.move_state('s1', 's2')
     self.assertEqual(self.sc.state_for('loop.H').memory, None)
     self.sc.validate()
开发者ID:AlexandreDecan,项目名称:sismic,代码行数:7,代码来源:test_model.py


示例17: test_history_not_in_compound

 def test_history_not_in_compound(self):
     yaml = """
     statechart:
       name: test
       root state:
         name: root
         initial: s1
         states:
           - name: s1
             parallel states:
              - name: s2
                type: shallow history
     """
     with self.assertRaises(exceptions.StatechartError) as cm:
         io.import_from_yaml(yaml)
     self.assertIn('cannot be used as a parent for', str(cm.exception))
开发者ID:EdwardBetts,项目名称:sismic,代码行数:16,代码来源:test_io.py


示例18: test_rename_change_memory

 def test_rename_change_memory(self):
     with open('tests/yaml/history.yaml') as f:
         self.sc = io.import_from_yaml(f)
     self.sc.state_for('loop.H').memory = 's1'
     self.sc.rename_state('s1', 's4')
     self.assertEqual(self.sc.state_for('loop.H').memory, 's4')
     self.sc.validate()
开发者ID:AlexandreDecan,项目名称:sismic,代码行数:7,代码来源:test_model.py


示例19: test_rename_change_state_name

    def test_rename_change_state_name(self):
        with open('tests/yaml/composite.yaml') as f:
            self.sc = io.import_from_yaml(f)

        state = self.sc.state_for('s1')
        self.sc.rename_state('s1', 'new s1')
        self.assertEqual(state.name, 'new s1')
开发者ID:AlexandreDecan,项目名称:sismic,代码行数:7,代码来源:test_model.py


示例20: test_rename_old_disappears

    def test_rename_old_disappears(self):
        with open('tests/yaml/composite.yaml') as f:
            self.sc = io.import_from_yaml(f)
        self.sc.rename_state('s1', 'new s1')

        self.assertFalse('s1' in self.sc.states)
        self.assertNotEqual('s1', self.sc.parent_for('s1a'))
        self.assertFalse('s1' in self.sc.children_for('root'))

        with self.assertRaises(exceptions.StatechartError) as cm:
            self.sc.state_for('s1')
        self.assertIn('State', str(cm.exception))
        self.assertIn('does not exist', str(cm.exception))

        with self.assertRaises(exceptions.StatechartError) as cm:
            self.sc.children_for('s1')
        self.assertIn('State', str(cm.exception))
        self.assertIn('does not exist', str(cm.exception))

        with self.assertRaises(exceptions.StatechartError) as cm:
            self.sc.parent_for('s1')
        self.assertIn('State', str(cm.exception))
        self.assertIn('does not exist', str(cm.exception))

        self.sc.validate()
开发者ID:AlexandreDecan,项目名称:sismic,代码行数:25,代码来源:test_model.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python site._init_pathinfo函数代码示例发布时间:2022-05-27
下一篇:
Python interpreter.Interpreter类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap