-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy path3-jakosc-kodu.py
65 lines (47 loc) · 1.19 KB
/
3-jakosc-kodu.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# -*- coding: utf-8 -*-
''' PYLINT, PEP '''
# correct
def long_function_name(
var_one, var_two, var_three,
var_four):
print(var_one)
foo = long_function_name(var_one, var_two,
var_three, var_four)
# or
foo = long_function_name(
var_one, var_two, var_three, var_four)
# incorrect
def long_function_name(
var_one, var_two,
var_three, var_four):
print(var_one)
foo = long_function_name(var_one, var_two,
var_three, var_four)
''' TESTY JEDNOSTKOWE '''
import unittest
class MathTest(unittest.TestCase):
def test_add(self):
self.assertEqual(2 + 3, 5)
def test_sub(self):
self.assertEqual(5 - 3, 3)
if __name__ == '__main__':
unittest.main()
# python python/tests/test.py
# Asercje w testach
self.assertEqual(2 + 3, 5)
self.assertAlmostEqual(0.1 + 0.2, 0.3, delta=1e-6)
self.assertNotEqual('żółw', u'Żółw')
self.assertTrue([0])
self.assertFalse([])
x = []
y = x
self.assertIs(x, y)
self.assertIn('x', ['x'])
self.assertIsInstance([], list)
self.assertIsNone(None)
self.assertItemsEqual((2, 3), [2, 3])
# Code coverage
# sudo pip install coverage
# coverage run python/hello.py
# coverage report -m
# coverage html