0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Python CodeとTest Code作成

0
Last updated at Posted at 2026-05-15

Python CodeとTest Code作成の備忘録

1.仮想環境の作成python -m venv 作成するフォルダ名

-mオプションPythonの内部機能を直接呼び出す。

2.Python CodeとTest Codeの作成

main.py
#Python Code
def add(a, b):
	return a + b

test.py
#Test Code
from main import add

def test_add():
	assert add(1,2) == 3

def test_add():
	assert add(-1,1) == 0

3.Pytestをインストールpip install pytest

4.test実行pytest

0
1
1

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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?