1 | import unittest |
||
2 | |||
3 | from coalib.bears.Bear import Bear |
||
4 | from coalib.collecting import Dependencies |
||
5 | |||
6 | |||
7 | class BearWithoutDeps(Bear): |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
![]() |
|||
8 | |||
9 | @staticmethod |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
10 | def get_dependencies(): |
||
11 | return [] |
||
12 | |||
13 | |||
14 | class ResolvableBear1(Bear): |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
15 | |||
16 | @staticmethod |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
17 | def get_dependencies(): |
||
18 | return [BearWithoutDeps] |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
19 | |||
20 | |||
21 | class ResolvableBear2(Bear): |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
22 | |||
23 | @staticmethod |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
24 | def get_dependencies(): |
||
25 | return [ResolvableBear1, BearWithoutDeps] |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Comprehensibility
Best Practice
introduced
by
|
|||
26 | |||
27 | |||
28 | class UnresolvableBear1(Bear): |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
29 | |||
30 | @staticmethod |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
31 | def get_dependencies(): |
||
32 | return [ResolvableBear1, BearWithoutDeps, UnresolvableBear3] |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Comprehensibility
Best Practice
introduced
by
Comprehensibility
Best Practice
introduced
by
|
|||
33 | |||
34 | |||
35 | class UnresolvableBear2(Bear): |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
36 | |||
37 | @staticmethod |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
38 | def get_dependencies(): |
||
39 | return [ResolvableBear1, BearWithoutDeps, UnresolvableBear1] |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Comprehensibility
Best Practice
introduced
by
Comprehensibility
Best Practice
introduced
by
|
|||
40 | |||
41 | |||
42 | class UnresolvableBear3(Bear): |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
43 | |||
44 | @staticmethod |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
45 | def get_dependencies(): |
||
46 | return [ResolvableBear1, BearWithoutDeps, UnresolvableBear2] |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Comprehensibility
Best Practice
introduced
by
Comprehensibility
Best Practice
introduced
by
|
|||
47 | |||
48 | |||
49 | class DependenciesTest(unittest.TestCase): |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
50 | |||
51 | def test_no_deps(self): |
||
52 | self.assertEqual( |
||
53 | len(Dependencies.resolve([BearWithoutDeps, |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
54 | BearWithoutDeps])), |
||
55 | 1) |
||
56 | |||
57 | def test_resolvable_deps(self): |
||
58 | self.assertEqual(Dependencies.resolve([ResolvableBear1, |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
59 | ResolvableBear2]), |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
60 | [BearWithoutDeps, ResolvableBear1, ResolvableBear2]) |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
61 | |||
62 | def test_unresolvable_deps(self): |
||
63 | self.assertRaises( |
||
64 | Dependencies.CircularDependencyError, |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
65 | Dependencies.resolve, |
||
66 | [UnresolvableBear1]) |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
67 |