19
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

1分でVim+Pythonのテスト環境をつくる

Last updated at Posted at 2013-07-11

##1.vimrcに下記を追加

nnoremap <C-p> :!python %<CR>

##2.対象のファイルの上下に下記を追加

unittest
import unittest

#(中略)

if __name__ == '__main__':
  unittest.main()

##3.テストを書く

テスト達
class PythonTest(unittest.TestCase):
  def test_zero(self):
    self.assertEqual(0, 0)
  def test_foo(self):
    self.assertEqual("foo", "foo")
  def test_bar(self):
    self.assertEqual("foo", "foo")

##4.該当のファイルをVimで開いたままControl+Pでテストを実行できる
スクリーンショット 2013-07-11 23.58.44.png

##5.サンプル様

sample
#! /usr/bin/env python
# -*- coding: utf-8 -*-

'評価するための関数達'

def evaluate(value):
  """そのまま返す関数"""
  return value


import unittest

class EvaluateTest(unittest.TestCase):
  def test_evaluate(self):
    value = 1
    evaluated_value = evaluate(value)
    self.assertEqual(value,evaluated_value)

if __name__ == '__main__':
  unittest.main()
19
20
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?