Skip to content

gonzalo123/kata_python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python dummy project for TDD

http://katayunos.com/

Activate virtualenv

python -m venv venv
source venv/bin/activate
pip install --upgrade pip 
pip install -r requirements.txt

run tests

pytest

or

python -m pytest tests/

pyenv tips

Simple test

tests/test_app.py

from app import foo

def test_foo():
    assert foo() is False, "first test must fail"

app.py

def foo():
    return False

Fixtures

tests/conftest.py

import pytest


@pytest.fixture()
def demo_fixture():
    return 1

Using fixture in test

tests/test_app.py

def test_fixture(demo_fixture):
    assert 1 == demo_fixture, "fixture demo"

Using parametrized tests

tests/test_app.py

import pytest

testdata = [
    ("0", 0),
    ("1", 1),
    ("2", 2),
]
@pytest.mark.parametrize("actual, expected", testdata)
def test_parametrize(actual, expected):
    assert int(actual) == expected

pytest doc

About

Python dummy project for TDD

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages