11# -*- coding: utf-8 -*-
22"""Tests for vcfpy.header"""
33
4- import sys
54import warnings
65
76import pytest
@@ -141,24 +140,14 @@ def test_header_alt_allele_header_line():
141140 line3 = header .AltAlleleHeaderLine .from_mapping ({"ID" : "DUP" , "Description" : "duplication" })
142141 assert line1 == line2
143142 assert line1 != line3
144- if sys .version_info < (3 , 6 ):
145- assert str (line1 ) == (
146- """AltAlleleHeaderLine('ALT', '<ID=DEL,Description="deletion">', """
147- """OrderedDict([('ID', 'DEL'), ('Description', 'deletion')]))"""
148- )
149- assert repr (line1 ) == (
150- """AltAlleleHeaderLine('ALT', '<ID=DEL,Description="deletion">', """
151- """OrderedDict([('ID', 'DEL'), ('Description', 'deletion')]))"""
152- )
153- else :
154- assert (
155- str (line1 ) == "AltAlleleHeaderLine('ALT', '<ID=DEL,Description=\" deletion\" >', "
156- "{'ID': 'DEL', 'Description': 'deletion'})"
157- )
158- assert (
159- repr (line1 ) == "AltAlleleHeaderLine('ALT', '<ID=DEL,Description=\" deletion\" >', "
160- "{'ID': 'DEL', 'Description': 'deletion'})"
161- )
143+ assert (
144+ str (line1 ) == "AltAlleleHeaderLine('ALT', '<ID=DEL,Description=\" deletion\" >', "
145+ "{'ID': 'DEL', 'Description': 'deletion'})"
146+ )
147+ assert (
148+ repr (line1 ) == "AltAlleleHeaderLine('ALT', '<ID=DEL,Description=\" deletion\" >', "
149+ "{'ID': 'DEL', 'Description': 'deletion'})"
150+ )
162151 assert line1 .value == '<ID=DEL,Description="deletion">'
163152 assert line1 .serialize () == '##ALT=<ID=DEL,Description="deletion">'
164153 with pytest .raises (TypeError ):
@@ -171,17 +160,8 @@ def test_header_contig_header_line():
171160 line3 = header .ContigHeaderLine .from_mapping ({"ID" : "2" , "length" : 123 })
172161 assert line1 == line2
173162 assert line1 != line3
174- if sys .version_info < (3 , 6 ):
175- assert (
176- str (line1 ) == "ContigHeaderLine('contig', '<ID=1,length=234>', OrderedDict([('ID', '1'), ('length', 234)]))"
177- )
178- assert (
179- repr (line1 )
180- == "ContigHeaderLine('contig', '<ID=1,length=234>', OrderedDict([('ID', '1'), ('length', 234)]))"
181- )
182- else :
183- assert str (line1 ) == "ContigHeaderLine('contig', '<ID=1,length=234>', {'ID': '1', 'length': 234})"
184- assert repr (line1 ) == "ContigHeaderLine('contig', '<ID=1,length=234>', {'ID': '1', 'length': 234})"
163+ assert str (line1 ) == "ContigHeaderLine('contig', '<ID=1,length=234>', {'ID': '1', 'length': 234})"
164+ assert repr (line1 ) == "ContigHeaderLine('contig', '<ID=1,length=234>', {'ID': '1', 'length': 234})"
185165 assert line1 .value == "<ID=1,length=234>"
186166 assert line1 .serialize () == "##contig=<ID=1,length=234>"
187167 with pytest .raises (TypeError ):
@@ -194,24 +174,14 @@ def test_header_filter_header_line():
194174 line3 = header .FilterHeaderLine .from_mapping ({"ID" : "q30" , "Description" : "Phred score <30" })
195175 assert line1 == line2
196176 assert line1 != line3
197- if sys .version_info < (3 , 6 ):
198- assert (
199- str (line1 ) == "FilterHeaderLine('FILTER', '<ID=PASS,Description=\" All filters passed\" >', "
200- "OrderedDict([('ID', 'PASS'), ('Description', 'All filters passed')]))"
201- )
202- assert (
203- repr (line1 ) == "FilterHeaderLine('FILTER', '<ID=PASS,Description=\" All filters passed\" >', "
204- "OrderedDict([('ID', 'PASS'), ('Description', 'All filters passed')]))"
205- )
206- else :
207- assert (
208- str (line1 ) == "FilterHeaderLine('FILTER', '<ID=PASS,Description=\" All filters passed\" >', "
209- "{'ID': 'PASS', 'Description': 'All filters passed'})"
210- )
211- assert (
212- repr (line1 ) == "FilterHeaderLine('FILTER', '<ID=PASS,Description=\" All filters passed\" >', "
213- "{'ID': 'PASS', 'Description': 'All filters passed'})"
214- )
177+ assert (
178+ str (line1 ) == "FilterHeaderLine('FILTER', '<ID=PASS,Description=\" All filters passed\" >', "
179+ "{'ID': 'PASS', 'Description': 'All filters passed'})"
180+ )
181+ assert (
182+ repr (line1 ) == "FilterHeaderLine('FILTER', '<ID=PASS,Description=\" All filters passed\" >', "
183+ "{'ID': 'PASS', 'Description': 'All filters passed'})"
184+ )
215185 assert line1 .value == '<ID=PASS,Description="All filters passed">'
216186 assert line1 .serialize () == '##FILTER=<ID=PASS,Description="All filters passed">'
217187 with pytest .raises (TypeError ):
@@ -224,24 +194,12 @@ def test_header_pedigree_header_line():
224194 line3 = header .PedigreeHeaderLine .from_mapping ({"ID" : "father" })
225195 assert line1 == line2
226196 assert line1 != line3
227- if sys .version_info < (3 , 6 ):
228- assert (
229- str (line1 ) == "PedigreeHeaderLine('PEDIGREE', '<ID=child,Father=father>', "
230- "OrderedDict([('ID', 'child'), ('Father', 'father')]))"
231- )
232- assert (
233- repr (line1 ) == "PedigreeHeaderLine('PEDIGREE', '<ID=child,Father=father>', "
234- "OrderedDict([('ID', 'child'), ('Father', 'father')]))"
235- )
236- else :
237- assert (
238- str (line1 )
239- == "PedigreeHeaderLine('PEDIGREE', '<ID=child,Father=father>', {'ID': 'child', 'Father': 'father'})"
240- )
241- assert (
242- repr (line1 )
243- == "PedigreeHeaderLine('PEDIGREE', '<ID=child,Father=father>', {'ID': 'child', 'Father': 'father'})"
244- )
197+ assert (
198+ str (line1 ) == "PedigreeHeaderLine('PEDIGREE', '<ID=child,Father=father>', {'ID': 'child', 'Father': 'father'})"
199+ )
200+ assert (
201+ repr (line1 ) == "PedigreeHeaderLine('PEDIGREE', '<ID=child,Father=father>', {'ID': 'child', 'Father': 'father'})"
202+ )
245203 assert line1 .value == "<ID=child,Father=father>"
246204 assert line1 .serialize () == "##PEDIGREE=<ID=child,Father=father>"
247205 with pytest .raises (TypeError ):
@@ -254,12 +212,8 @@ def test_header_sample_header_line():
254212 line3 = header .SampleHeaderLine .from_mapping ({"ID" : "sample2" })
255213 assert line1 == line2
256214 assert line1 != line3
257- if sys .version_info < (3 , 6 ):
258- assert str (line1 ) == "SampleHeaderLine('SAMPLE', '<ID=sample1>', OrderedDict([('ID', 'sample1')]))"
259- assert repr (line1 ) == "SampleHeaderLine('SAMPLE', '<ID=sample1>', OrderedDict([('ID', 'sample1')]))"
260- else :
261- assert str (line1 ) == "SampleHeaderLine('SAMPLE', '<ID=sample1>', {'ID': 'sample1'})"
262- assert repr (line1 ) == "SampleHeaderLine('SAMPLE', '<ID=sample1>', {'ID': 'sample1'})"
215+ assert str (line1 ) == "SampleHeaderLine('SAMPLE', '<ID=sample1>', {'ID': 'sample1'})"
216+ assert repr (line1 ) == "SampleHeaderLine('SAMPLE', '<ID=sample1>', {'ID': 'sample1'})"
263217 assert line1 .value == "<ID=sample1>"
264218 assert line1 .serialize () == "##SAMPLE=<ID=sample1>"
265219 with pytest .raises (TypeError ):
@@ -278,26 +232,16 @@ def test_header_info_header_line():
278232 )
279233 assert line1 == line2
280234 assert line1 != line3
281- if sys .version_info < (3 , 6 ):
282- assert (
283- str (line1 ) == "InfoHeaderLine('INFO', '<ID=SVTYPE,Number=1,Type=String>', "
284- "OrderedDict([('ID', 'SVTYPE'), ('Number', 1), ('Type', 'String')]))"
285- )
286- assert (
287- repr (line1 ) == "InfoHeaderLine('INFO', '<ID=SVTYPE,Number=1,Type=String>', "
288- "OrderedDict([('ID', 'SVTYPE'), ('Number', 1), ('Type', 'String')]))"
289- )
290- else :
291- assert (
292- str (line1 )
293- == "InfoHeaderLine('INFO', '<ID=SVTYPE,Number=1,Type=String,Description=\" Type of structural variant\" >', "
294- "{'ID': 'SVTYPE', 'Number': 1, 'Type': 'String', 'Description': 'Type of structural variant'})"
295- )
296- assert (
297- repr (line1 )
298- == "InfoHeaderLine('INFO', '<ID=SVTYPE,Number=1,Type=String,Description=\" Type of structural variant\" >', "
299- "{'ID': 'SVTYPE', 'Number': 1, 'Type': 'String', 'Description': 'Type of structural variant'})"
300- )
235+ assert (
236+ str (line1 )
237+ == "InfoHeaderLine('INFO', '<ID=SVTYPE,Number=1,Type=String,Description=\" Type of structural variant\" >', "
238+ "{'ID': 'SVTYPE', 'Number': 1, 'Type': 'String', 'Description': 'Type of structural variant'})"
239+ )
240+ assert (
241+ repr (line1 )
242+ == "InfoHeaderLine('INFO', '<ID=SVTYPE,Number=1,Type=String,Description=\" Type of structural variant\" >', "
243+ "{'ID': 'SVTYPE', 'Number': 1, 'Type': 'String', 'Description': 'Type of structural variant'})"
244+ )
301245 assert line1 .value == '<ID=SVTYPE,Number=1,Type=String,Description="Type of structural variant">'
302246 assert line1 .serialize () == '##INFO=<ID=SVTYPE,Number=1,Type=String,Description="Type of structural variant">'
303247 with pytest .raises (TypeError ):
@@ -316,24 +260,14 @@ def test_header_format_header_line():
316260 )
317261 assert line1 == line2
318262 assert line1 != line3
319- if sys .version_info < (3 , 6 ):
320- assert (
321- str (line1 ) == "FormatHeaderLine('FORMAT', '<ID=AD,Number=R,Type=Integer>', "
322- "OrderedDict([('ID', 'AD'), ('Number', 'R'), ('Type', 'Integer')]))"
323- )
324- assert (
325- repr (line1 ) == "FormatHeaderLine('FORMAT', '<ID=AD,Number=R,Type=Integer>', "
326- "OrderedDict([('ID', 'AD'), ('Number', 'R'), ('Type', 'Integer')]))"
327- )
328- else :
329- assert (
330- str (line1 ) == "FormatHeaderLine('FORMAT', '<ID=AD,Number=R,Type=Integer,Description=\" Allelic depths\" >', "
331- "{'ID': 'AD', 'Number': 'R', 'Type': 'Integer', 'Description': 'Allelic depths'})"
332- )
333- assert (
334- repr (line1 ) == "FormatHeaderLine('FORMAT', '<ID=AD,Number=R,Type=Integer,Description=\" Allelic depths\" >', "
335- "{'ID': 'AD', 'Number': 'R', 'Type': 'Integer', 'Description': 'Allelic depths'})"
336- )
263+ assert (
264+ str (line1 ) == "FormatHeaderLine('FORMAT', '<ID=AD,Number=R,Type=Integer,Description=\" Allelic depths\" >', "
265+ "{'ID': 'AD', 'Number': 'R', 'Type': 'Integer', 'Description': 'Allelic depths'})"
266+ )
267+ assert (
268+ repr (line1 ) == "FormatHeaderLine('FORMAT', '<ID=AD,Number=R,Type=Integer,Description=\" Allelic depths\" >', "
269+ "{'ID': 'AD', 'Number': 'R', 'Type': 'Integer', 'Description': 'Allelic depths'})"
270+ )
337271 assert line1 .value == '<ID=AD,Number=R,Type=Integer,Description="Allelic depths">'
338272 assert line1 .serialize () == '##FORMAT=<ID=AD,Number=R,Type=Integer,Description="Allelic depths">'
339273 with pytest .raises (TypeError ):
0 commit comments