Disable individual Python unit tests temporarily

后端 未结 7 818
臣服心动
臣服心动 2020-12-23 08:35

How can individual unit tests be temporarily disabled when using the unittest module in Python?

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-23 09:08

    The latest version (2.7 - unreleased) supports test skipping/disabling like so. You could just get this module and use it on your existing Python install. It will probably work.

    Before this, I used to rename the tests I wanted skipped to xtest_testname from test_testname.


    Here's a quick elisp script to do this. My elisp is a little rusty so I apologise in advance for any problems it has. Untested.

      (defun disable_enable_test ()
      (interactive "")
      (save-excursion
        (beginning-of-line)
        (search-forward "def")
        (forward-char)
        (if (looking-at "disable_")
        (zap-to-char 1 ?_)
          (insert "disable_"))))
    

提交回复
热议问题