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


Python EditCommand.execute方法代码示例

本文整理汇总了Python中topydo.commands.EditCommand.EditCommand.execute方法的典型用法代码示例。如果您正苦于以下问题:Python EditCommand.execute方法的具体用法?Python EditCommand.execute怎么用?Python EditCommand.execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在topydo.commands.EditCommand.EditCommand的用法示例。


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

示例1: test_edit6

# 需要导入模块: from topydo.commands.EditCommand import EditCommand [as 别名]
# 或者: from topydo.commands.EditCommand.EditCommand import execute [as 别名]
    def test_edit6(self):
        """ Throw an error with invalid argument containing special characters. """
        command = EditCommand([u("Fo\u00d3B\u0105r"), "Bar"], self.todolist, self.out, self.error, None)
        command.execute()

        self.assertFalse(self.todolist.is_dirty())
        self.assertEqual(self.errors, u("Invalid todo number given: Fo\u00d3B\u0105r.\n"))
开发者ID:netimen,项目名称:topydo,代码行数:9,代码来源:EditCommandTest.py

示例2: test_edit4

# 需要导入模块: from topydo.commands.EditCommand import EditCommand [as 别名]
# 或者: from topydo.commands.EditCommand.EditCommand import execute [as 别名]
    def test_edit4(self):
        """ Throw an error with pointing invalid argument. """
        command = EditCommand(["Bar", "5"], self.todolist, self.out, self.error, None)
        command.execute()

        self.assertFalse(self.todolist.is_dirty())
        self.assertEqual(self.errors, "Invalid todo number given: 5.\n")
开发者ID:netimen,项目名称:topydo,代码行数:9,代码来源:EditCommandTest.py

示例3: test_edit3

# 需要导入模块: from topydo.commands.EditCommand import EditCommand [as 别名]
# 或者: from topydo.commands.EditCommand.EditCommand import execute [as 别名]
    def test_edit3(self):
        """ Throw an error after invalid todo number given as argument. """
        command = EditCommand(["FooBar"], self.todolist, self.out, self.error, None)
        command.execute()

        self.assertFalse(self.todolist.is_dirty())
        self.assertEqual(self.errors, "Invalid todo number given.\n")
开发者ID:netimen,项目名称:topydo,代码行数:9,代码来源:EditCommandTest.py

示例4: test_help

# 需要导入模块: from topydo.commands.EditCommand import EditCommand [as 别名]
# 或者: from topydo.commands.EditCommand.EditCommand import execute [as 别名]
    def test_help(self):
        command = EditCommand(["help"], self.todolist, self.out, self.error,
                              None)
        command.execute()

        self.assertEqual(self.output, "")
        self.assertEqual(self.errors,
                         command.usage() + "\n\n" + command.help() + "\n")
开发者ID:bram85,项目名称:topydo,代码行数:10,代码来源:test_edit_command.py

示例5: test_edit_editor6

# 需要导入模块: from topydo.commands.EditCommand import EditCommand [as 别名]
# 或者: from topydo.commands.EditCommand.EditCommand import execute [as 别名]
    def test_edit_editor6(self, mock_call):
        """ Ultimate fallback is vi """
        mock_call.return_value = 0

        command = EditCommand([], self.todolist, self.out, self.error, None)
        command.execute()

        self.assertEqual(self.errors, "")
        mock_call.assert_called_once_with(['vi', config().todotxt()])
开发者ID:bram85,项目名称:topydo,代码行数:11,代码来源:test_edit_command.py

示例6: test_edit_editor3

# 需要导入模块: from topydo.commands.EditCommand import EditCommand [as 别名]
# 或者: from topydo.commands.EditCommand.EditCommand import execute [as 别名]
    def test_edit_editor3(self, mock_call):
        """ Editor on commandline overrides $TOPYDO_EDITOR """
        mock_call.return_value = 0

        command = EditCommand(["-E", "foo"], self.todolist, self.out, self.error, None)
        command.execute()

        self.assertEqual(self.errors, "")
        mock_call.assert_called_once_with(['foo', config().todotxt()])
开发者ID:bram85,项目名称:topydo,代码行数:11,代码来源:test_edit_command.py

示例7: test_edit1

# 需要导入模块: from topydo.commands.EditCommand import EditCommand [as 别名]
# 或者: from topydo.commands.EditCommand.EditCommand import execute [as 别名]
    def test_edit1(self, mock_open_in_editor):
        """ Preserve dependencies after editing. """
        mock_open_in_editor.return_value = 0

        command = EditCommand(["1"], self.todolist, self.out, self.error, None)
        command.execute()

        self.assertTrue(self.todolist.is_dirty())
        self.assertEqual(self.errors, "")
        self.assertEqual(self.todolist.print_todos(), u("Bar p:1 @test\nBaz @test\nFo\u00f3B\u0105\u017a\nFoo id:1"))
开发者ID:netimen,项目名称:topydo,代码行数:12,代码来源:EditCommandTest.py

示例8: test_edit_editor2

# 需要导入模块: from topydo.commands.EditCommand import EditCommand [as 别名]
# 或者: from topydo.commands.EditCommand.EditCommand import execute [as 别名]
    def test_edit_editor2(self, mock_call):
        """ $TOPYDO_EDITOR overrides $EDITOR """
        mock_call.return_value = 0

        todotxt = config().todotxt()

        command = EditCommand([], self.todolist, self.out, self.error, None)
        command.execute()

        self.assertEqual(self.errors, "")
        mock_call.assert_called_once_with(['nano', todotxt])
开发者ID:bram85,项目名称:topydo,代码行数:13,代码来源:test_edit_command.py

示例9: test_edit_editor5

# 需要导入模块: from topydo.commands.EditCommand import EditCommand [as 别名]
# 或者: from topydo.commands.EditCommand.EditCommand import execute [as 别名]
    def test_edit_editor5(self, mock_call):
        """ Editor in configuration file overrides $EDITOR """
        mock_call.return_value = 0

        config(p_overrides={('edit', 'editor'): 'foo'})

        command = EditCommand([], self.todolist, self.out, self.error, None)
        command.execute()

        self.assertEqual(self.errors, "")
        mock_call.assert_called_once_with(['foo', config().todotxt()])
开发者ID:bram85,项目名称:topydo,代码行数:13,代码来源:test_edit_command.py

示例10: test_edit5

# 需要导入模块: from topydo.commands.EditCommand import EditCommand [as 别名]
# 或者: from topydo.commands.EditCommand.EditCommand import execute [as 别名]
    def test_edit5(self, mock_open_in_editor, mock_todos_from_temp):
        """ Don't let to delete todos acidentally while editing. """
        mock_open_in_editor.return_value = 0
        mock_todos_from_temp.return_value = [Todo("Only one line")]

        command = EditCommand(["1", "Bar"], self.todolist, self.out, self.error, None)
        command.execute()

        self.assertFalse(self.todolist.is_dirty())
        self.assertEqual(self.errors, "Number of edited todos is not equal to number of supplied todo IDs.\n")
        self.assertEqual(self.todolist.print_todos(), u("Foo id:1\nBar p:1 @test\nBaz @test\nFo\u00f3B\u0105\u017a"))
开发者ID:netimen,项目名称:topydo,代码行数:13,代码来源:EditCommandTest.py

示例11: test_edit2

# 需要导入模块: from topydo.commands.EditCommand import EditCommand [as 别名]
# 或者: from topydo.commands.EditCommand.EditCommand import execute [as 别名]
    def test_edit2(self, mock_open_in_editor, mock_todos_from_temp):
        """ Edit some todo. """
        mock_open_in_editor.return_value = 0
        mock_todos_from_temp.return_value = [Todo("Lazy Cat")]

        command = EditCommand(["Bar"], self.todolist, self.out, self.error, None)
        command.execute()

        self.assertTrue(self.todolist.is_dirty())
        self.assertEqual(self.errors, "")
        self.assertEqual(self.todolist.print_todos(), u("Foo id:1\nBaz @test\nFo\u00f3B\u0105\u017a\nLazy Cat"))
开发者ID:netimen,项目名称:topydo,代码行数:13,代码来源:EditCommandTest.py

示例12: test_edit7

# 需要导入模块: from topydo.commands.EditCommand import EditCommand [as 别名]
# 或者: from topydo.commands.EditCommand.EditCommand import execute [as 别名]
    def test_edit7(self, mock_open_in_editor, mock_todos_from_temp):
        """ Edit todo with special characters. """
        mock_open_in_editor.return_value = 0
        mock_todos_from_temp.return_value = [Todo("Lazy Cat")]

        command = EditCommand([u("Fo\u00f3B\u0105\u017a")], self.todolist, self.out, self.error, None)
        command.execute()

        self.assertTrue(self.todolist.is_dirty())
        self.assertEqual(self.errors, "")
        self.assertEqual(self.todolist.print_todos(), u("Foo id:1\nBar p:1 @test\nBaz @test\nLazy Cat"))
开发者ID:netimen,项目名称:topydo,代码行数:13,代码来源:EditCommandTest.py

示例13: test_edit_archive

# 需要导入模块: from topydo.commands.EditCommand import EditCommand [as 别名]
# 或者: from topydo.commands.EditCommand.EditCommand import execute [as 别名]
    def test_edit_archive(self, mock_call):
        """ Edit archive file. """
        mock_call.return_value = 0

        archive = config().archive()

        command = EditCommand(["-d"], self.todolist, self.out, self.error,
                              None)
        command.execute()

        self.assertEqual(self.errors, "")
        mock_call.assert_called_once_with(['vi', archive])
开发者ID:bram85,项目名称:topydo,代码行数:14,代码来源:test_edit_command.py

示例14: test_edit01

# 需要导入模块: from topydo.commands.EditCommand import EditCommand [as 别名]
# 或者: from topydo.commands.EditCommand.EditCommand import execute [as 别名]
    def test_edit01(self, mock_open_in_editor, mock_todos_from_temp, mock_is_edited):
        """ Preserve dependencies after editing. """
        mock_open_in_editor.return_value = 0
        mock_todos_from_temp.return_value = [Todo('Foo id:1')]
        mock_is_edited.return_value = True

        command = EditCommand(["1"], self.todolist, self.out, self.error, None)
        command.execute()

        self.assertEqual(self.errors, "")
        self.assertTrue(self.todolist.dirty)
        self.assertEqual(self.todolist.print_todos(), u"Bar p:1 @test\nBaz @test\nFo\u00f3B\u0105\u017a\nFoo id:1")
开发者ID:bram85,项目名称:topydo,代码行数:14,代码来源:test_edit_command.py

示例15: test_edit07

# 需要导入模块: from topydo.commands.EditCommand import EditCommand [as 别名]
# 或者: from topydo.commands.EditCommand.EditCommand import execute [as 别名]
    def test_edit07(self, mock_open_in_editor, mock_todos_from_temp, mock_is_edited):
        """ Don't perform write if tempfile is unchanged """
        mock_open_in_editor.return_value = 0
        mock_todos_from_temp.return_value = [Todo('Only one line')]
        mock_is_edited.return_value = False

        command = EditCommand(["1", "Bar"], self.todolist, self.out,
                              self.error, None)
        command.execute()

        self.assertFalse(self.todolist.dirty)
        self.assertEqual(self.errors, "Editing aborted. Nothing to do.\n")
        self.assertEqual(self.todolist.print_todos(), u"Foo id:1\nBar p:1 @test\nBaz @test\nFo\u00f3B\u0105\u017a")
开发者ID:bram85,项目名称:topydo,代码行数:15,代码来源:test_edit_command.py


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