【问题标题】:Running py.test from emacs从 emacs 运行 py.test
【发布时间】:2010-04-14 07:14:55
【问题描述】:

如果正在编辑的文件的名称以 test_ 开头,我希望 C-c C-c 运行 py.test 并在另一个缓冲区中显示输出,否则正常运行 py-execute-buffer。我该怎么做?我正在使用带有 python 模式的 emacs 23.1.1,并且可以从命令行访问 py.test。

【问题讨论】:

    标签: python emacs pytest


    【解决方案1】:

    这没有经过特别充分的测试;这只是一个粗略的想法。

    (defun py-do-it ()
      (interactive)
      (if (string-match
           (rx bos "test_")
           (file-name-nondirectory (buffer-file-name)))
          (compile "py.test")
        (py-execute-buffer)))
    
    (add-hook 'python-mode-hook
              (lambda ()
                (local-set-key
                 (kbd "F5")                 ;or whatever
                 'py-do-it)))
    

    【讨论】:

    • 在使用它一段时间后,我决定我希望 py.test 仅在当前缓冲区上运行,所以我将 (compile "py.test") 替换为 (shell-command (concat “py.test”(缓冲区文件名)))
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-03-25
    • 2018-12-08
    • 1970-01-01
    • 2017-10-19
    • 2013-06-13
    • 2011-08-10
    • 1970-01-01
    相关资源
    最近更新 更多