Conditions | 1 |
Total Lines | 52 |
Code Lines | 48 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | ''' |
||
30 | def test_singletons(self): |
||
31 | g = Graph().traversal() |
||
32 | bytecode = g.withStrategies(ReadOnlyStrategy()).bytecode |
||
33 | assert 1 == len(bytecode.source_instructions) |
||
34 | assert 2 == len(bytecode.source_instructions[0]) |
||
35 | assert "withStrategies" == bytecode.source_instructions[0][0] |
||
36 | assert ReadOnlyStrategy() == bytecode.source_instructions[0][1] |
||
37 | assert "ReadOnlyStrategy" == str(bytecode.source_instructions[0][1]) |
||
38 | assert hash(ReadOnlyStrategy()) == hash(bytecode.source_instructions[0][1]) |
||
39 | assert 0 == len(g.traversal_strategies.traversal_strategies) # these strategies are proxies |
||
40 | ## |
||
41 | g = g.withStrategies(ReadOnlyStrategy(), IncidentToAdjacentStrategy()) |
||
42 | bytecode = g.bytecode |
||
43 | assert 1 == len(bytecode.source_instructions) |
||
44 | assert 3 == len(bytecode.source_instructions[0]) |
||
45 | assert "withStrategies" == bytecode.source_instructions[0][0] |
||
46 | assert ReadOnlyStrategy() == bytecode.source_instructions[0][1] |
||
47 | assert IncidentToAdjacentStrategy() == bytecode.source_instructions[0][2] |
||
48 | ## |
||
49 | bytecode = g.V().bytecode |
||
50 | assert 1 == len(bytecode.source_instructions) |
||
51 | assert 3 == len(bytecode.source_instructions[0]) |
||
52 | assert "withStrategies" == bytecode.source_instructions[0][0] |
||
53 | assert ReadOnlyStrategy() == bytecode.source_instructions[0][1] |
||
54 | assert IncidentToAdjacentStrategy() == bytecode.source_instructions[0][2] |
||
55 | assert 1 == len(bytecode.step_instructions) |
||
56 | assert "V" == bytecode.step_instructions[0][0] |
||
57 | ## |
||
58 | bytecode = g.withoutStrategies(ReadOnlyStrategy()).V().bytecode |
||
59 | assert 2 == len(bytecode.source_instructions) |
||
60 | assert 3 == len(bytecode.source_instructions[0]) |
||
61 | assert 2 == len(bytecode.source_instructions[1]) |
||
62 | assert "withStrategies" == bytecode.source_instructions[0][0] |
||
63 | assert ReadOnlyStrategy() == bytecode.source_instructions[0][1] |
||
64 | assert IncidentToAdjacentStrategy() == bytecode.source_instructions[0][2] |
||
65 | assert "withoutStrategies" == bytecode.source_instructions[1][0] |
||
66 | assert ReadOnlyStrategy() == bytecode.source_instructions[1][1] |
||
67 | assert 1 == len(bytecode.step_instructions) |
||
68 | assert "V" == bytecode.step_instructions[0][0] |
||
69 | ## |
||
70 | bytecode = g.withoutStrategies(ReadOnlyStrategy(), LazyBarrierStrategy()).V().bytecode |
||
71 | assert 2 == len(bytecode.source_instructions) |
||
72 | assert 3 == len(bytecode.source_instructions[0]) |
||
73 | assert 3 == len(bytecode.source_instructions[1]) |
||
74 | assert "withStrategies" == bytecode.source_instructions[0][0] |
||
75 | assert ReadOnlyStrategy() == bytecode.source_instructions[0][1] |
||
76 | assert IncidentToAdjacentStrategy() == bytecode.source_instructions[0][2] |
||
77 | assert "withoutStrategies" == bytecode.source_instructions[1][0] |
||
78 | assert ReadOnlyStrategy() == bytecode.source_instructions[1][1] |
||
79 | assert LazyBarrierStrategy() == bytecode.source_instructions[1][2] |
||
80 | assert 1 == len(bytecode.step_instructions) |
||
81 | assert "V" == bytecode.step_instructions[0][0] |
||
82 | |||
103 |