Skip to content

Instantly share code, notes, and snippets.

View Weyzu's full-sized avatar

Wiktor Żurawik Weyzu

  • King
  • Berlin, Germany
  • X @Weyzu
View GitHub Profile
@Weyzu
Weyzu / keybase.md
Last active September 3, 2016 23:28
keybase.md

Keybase proof

I hereby claim:

  • I am Weyzu on github.
  • I am weyzu (https://keybase.io/weyzu) on keybase.
  • I have a public key whose fingerprint is 5434 FC70 B252 9C4F 8E42 8105 A0DF 0AAD 6F9B 46BD

To claim this, I am signing this object:

def is_leap_year(year):
if year % 400 == 0:
return True
if year % 100 == 0:
return False
return year % 4 == 0
from unittest import TestCase
from pres.utils import is_leap_year
class TestIsLeapYear(TestCase):
def test_returns_true_for_leap_years(self):
self.assertTrue(is_leap_year(2020))
# NOSE
from nose.tools import assert_equal, assert_not_equal
from pres.utils import is_leap_year
def test_is_leap_year_returns_true_for_leap_years():
assert_equal(is_leap_year(2020))
def test_is_leap_year_returns_false_for_non_leap_years():
======================================================================
FAIL: test_utils.test_is_leap_year_returns_true_for_leap_year
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/heck/.virtualenvs/pytest/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
self.test(*self.arg)
File "/home/heck/Workplace/pytest_presentation/tests/nose/test_utils.py", line 13, in test_is_leap_year_returns_true_for_leap_year
assert_true(is_leap_year(2029))
AssertionError: False is not true
_____________ test_is_leap_year_returns_true_for_leap_year _____________
def test_is_leap_year_returns_true_for_leap_year():
> assert is_leap_year(2021)
E assert False
E + where False = is_leap_year(2021)
tests/test_utils.py:5: AssertionError
___________ test_get_user_stats_returns_full_user_statistics ___________
def test_get_user_stats_returns_full_user_statistics():
> assert get_user_stats(username='Pinky') =={
"elections_hacked": 11,
"is_laserproof": False,
}
E AssertionError: assert {'elections_h...proof': False} == {'elections_ha...proof': False}
E Omitting 1 identical items, use -vv to show
E Differing items:
def test_is_leap_year_returns_true_for_leap_years():
leap_years = [2016, 2020, 2023, 2028, 2400]
for leap_year in leap_years:
yield assert_is_leap, leap_year
def assert_is_leap(year):
assert_true(is_leap_year(year))
@pytest.mark.parametrize('leap_year', [2016, 2020, 2024, 2028, 2400])
def test_is_leap_year_returns_true_for_leap_years(leap_year):
assert is_leap_year(leap_year)
@pytest.fixture
def person():
return PersonRepository().create(name='Andrew', age=20)