1
+ import pytest
2
+
3
+ from common import common_languages
4
+
5
+
6
+ @pytest .fixture ()
7
+ def programmers ():
8
+ return dict (bob = ['JS' , 'PHP' , 'Python' , 'Perl' , 'Java' ],
9
+ tim = ['Python' , 'Haskell' , 'C++' , 'JS' ],
10
+ sara = ['Perl' , 'C' , 'Java' , 'Python' , 'JS' ],
11
+ paul = ['C++' , 'JS' , 'Python' ])
12
+
13
+
14
+ def test_common_languages (programmers ):
15
+ expected = ['JS' , 'Python' ]
16
+ actual = common_languages (programmers )
17
+ assert sorted (list (actual )) == expected
18
+
19
+
20
+ def test_adding_programmer_without_js (programmers ):
21
+ programmers ['sue' ] = ['Scala' , 'Python' ]
22
+ expected = ['Python' ]
23
+ actual = common_languages (programmers )
24
+ assert list (actual ) == expected
25
+
26
+
27
+ def test_adding_programmer_without_js_nor_python (programmers ):
28
+ programmers ['fabio' ] = ['PHP' ]
29
+ expected = []
30
+ actual = common_languages (programmers )
31
+ assert list (actual ) == expected
32
+
33
+
34
+ def test_common_languages_adding_new_common_language (programmers ):
35
+ programmers ['bob' ].append ('C++' )
36
+ programmers ['sara' ].append ('C++' )
37
+ expected = ['C++' , 'JS' , 'Python' ]
38
+ actual = common_languages (programmers )
39
+ assert sorted (list (actual )) == expected
0 commit comments