@@ -51,5 +51,49 @@ from ga4gh.protocol import Variant
51
51
variant = Variant()
52
52
```
53
53
54
- ## Tests
55
- Tests should avoid use of the ` assert ` keyword and instead use the methods that ` unittest ` provides.
54
+ ## Tests
55
+ Unit tests should have descriptive
56
+ method names and should aim to be short, simple and isolated. Where complex
57
+ testing is required, we should delegate the verification to another
58
+ method. For example,
59
+
60
+ ``` python
61
+ class TestGenotypeConversion (unittest .TestCase ):
62
+ """
63
+ Tests the conversion of VCF genotypes to GA4GH values.
64
+ """
65
+ def verifyConversion (self , vcfGenotype , vcfPhaseset ,
66
+ ga4ghGenotype , ga4ghPhaseset ):
67
+ """
68
+ Verifies that the convertGenotype function properly converts the
69
+ specified VCF genotype and phaseset values into the specified
70
+ GA4GH genotype and phaseset values.
71
+ """
72
+ self .assertEqual(
73
+ (ga4ghGenotype, ga4ghPhaseset),
74
+ variants.convertVcfGenotype(vcfGenotype, vcfPhaseset))
75
+
76
+ def testUnphasedNoCall (self ):
77
+ self .verifyConversion(" ./." , " 0" , [- 1 ], None )
78
+
79
+ def testUnphasedSecondHalfCall (self ):
80
+ self .verifyConversion(" ./0" , " 25" , [- 1 ], None )
81
+
82
+ # etc.
83
+ ```
84
+
85
+ Tests should avoid use of the ` assert ` keyword and instead use the
86
+ methods that ` unittest ` provides.
87
+
88
+ ## Docstring comments
89
+
90
+ All public methods and functions should have docstring comments, and should
91
+ follow the conventions of [ PEP 257] ( https://www.python.org/dev/peps/pep-0257/ ) .
92
+
93
+ The exception to this rule is for unit tests, which should have descriptive
94
+ method names, and no docstring comments. (The reason for this is that
95
+ nosetests prints out the docstring comment rather than the methodname
96
+ when running ` nosetests -v ` , which seems less useful.) See above for an
97
+ example of the recommended structure for unit tests.
98
+
99
+
0 commit comments