Package: python-intervaltree-bio / 1.0.1-4

offline-test-data.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Description: Allow tests to be run using pre-downloaded data files
 allow passing --datadir to pytest to use local data files without
 attempting a download.
Author: Afif Elghraoui <afif@debian.org>
Forwarded: https://github.com/konstantint/intervaltree-bio/pull/2
Last-Update: 2016-12-10
--- python-intervaltree-bio.orig/tests/genomeintervaltree_test.py
+++ python-intervaltree-bio/tests/genomeintervaltree_test.py
@@ -13,11 +13,9 @@
 
 from intervaltree_bio import GenomeIntervalTree, UCSCTable
 
-def test_knownGene():
+def test_knownGene(base_url):
     # To speed up testing, we'll download the file and reuse the downloaded copy
-    knownGene_url = 'http://hgdownload.cse.ucsc.edu/goldenpath/hg19/database/knownGene.txt.gz'
-    # Mirror. Slightly faster and more stable, I believe:
-    knownGene_url = 'http://kt.era.ee/distribute/pyintervaltree/knownGene.txt.gz'
+    knownGene_url = base_url + 'knownGene.txt.gz'
 
     # To speed up testing, we'll download the file and reuse the downloaded copy
     knownGene_file, headers = urlretrieve(knownGene_url)
@@ -39,16 +37,14 @@
     assert len(result) == 3
     assert result[0].data == result[1].data and result[0].data == result[2].data
     
-def test_ensGene():
+def test_ensGene(base_url):
     # Smoke-test we can at least read ensGene.
-    ensGene_url = 'http://hgdownload.cse.ucsc.edu/goldenpath/hg19/database/ensGene.txt.gz'
-    ensGene_url = 'http://kt.era.ee/distribute/pyintervaltree/ensGene.txt.gz'
+    ensGene_url = base_url + 'ensGene.txt.gz'
     ensGene = GenomeIntervalTree.from_table(url=ensGene_url, mode='cds', parser=UCSCTable.ENS_GENE)
     assert len(ensGene) == 204940
 
-def test_refGene():
+def test_refGene(base_url):
     # Smoke-test for refGene
-    refGene_url = 'http://hgdownload.cse.ucsc.edu/goldenpath/hg19/database/refGene.txt.gz'
-    refGene_url = 'http://kt.era.ee/distribute/pyintervaltree/refGene.txt.gz'
+    refGene_url = base_url + 'refGene.txt.gz'
     refGene = GenomeIntervalTree.from_table(url=refGene_url, mode='tx', parser=UCSCTable.REF_GENE)
     assert len(refGene) == 52350  # NB: Some time ago it was 50919, hence it seems the table data changes on UCSC and eventually the mirror and UCSC won't be the same.
--- /dev/null
+++ python-intervaltree-bio/conftest.py
@@ -0,0 +1,20 @@
+import os
+
+import pytest
+
+def pytest_addoption(parser):
+    parser.addoption("--datadir",
+                     help="path to data files")
+
+def pytest_generate_tests(metafunc):
+    if 'base_url' in metafunc.fixturenames:
+        if metafunc.config.option.datadir:
+            base_url = ('file://'
+                        + os.path.abspath(metafunc.config.option.datadir)
+                        + os.sep)
+        else:
+            base_url = 'http://hgdownload.cse.ucsc.edu/goldenpath/hg19/database/'
+            # Mirror. Slightly faster and more stable, I believe -KT
+
+            base_url = 'http://kt.era.ee/distribute/pyintervaltree/'
+        metafunc.parametrize('base_url',[base_url])