Skip to content

Commit

Permalink
make test temporary directories not in the "test" folder
Browse files Browse the repository at this point in the history
This prevented the execution of the tests post-installation
  • Loading branch information
mr-c committed Dec 26, 2024
1 parent c8052f3 commit c1838a9
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 57 deletions.
15 changes: 5 additions & 10 deletions pybedtools/test/test_1.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
import pybedtools
import os, difflib, sys
import tempfile

from pybedtools import featurefuncs
import pytest

import threading
import warnings
from .tfuncs import test_tempdir

unwriteable = "unwriteable"


def setup_module():
if not os.path.exists(test_tempdir):
os.system("mkdir -p %s" % test_tempdir)
pybedtools.set_tempdir(test_tempdir)


def teardown_module():
if os.path.exists(test_tempdir):
os.system("rm -r %s" % test_tempdir)
pybedtools.cleanup()


Expand Down Expand Up @@ -67,7 +60,8 @@ def cleanup_unwriteable():
"""
if os.path.exists(unwriteable):
os.system("rm -rf %s" % unwriteable)
pybedtools.set_tempdir(test_tempdir)
tempfile.tempdir = None
pybedtools.set_tempdir(tempfile.gettempdir())


def test_interval_index():
Expand Down Expand Up @@ -503,6 +497,7 @@ def test_sequence():
For example, the first 100 bases of a chromosome are defined as
chromStart=0, chromEnd=100, and span the bases numbered 0-99. """

test_tempdir = os.path.abspath(tempfile.gettempdir())
fi = os.path.join(test_tempdir, "test.fasta")

s = """
Expand Down
9 changes: 0 additions & 9 deletions pybedtools/test/test_cbedtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,8 @@
from pybedtools import Interval, IntervalFile
import pybedtools
import pytest
from .tfuncs import test_tempdir

def setup_module():
if not os.path.exists(test_tempdir):
os.system("mkdir -p %s" % test_tempdir)
pybedtools.set_tempdir(test_tempdir)


def teardown_module():
if os.path.exists(test_tempdir):
os.system("rm -r %s" % test_tempdir)
pybedtools.cleanup()

PATH = os.path.dirname(__file__)
Expand Down
2 changes: 1 addition & 1 deletion pybedtools/test/test_contrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pybedtools import Interval

# from pybedtools.contrib import Classifier
from .tfuncs import setup_module, teardown_module, testdir, test_tempdir, unwriteable
from .tfuncs import teardown_module

# model for gdc.
# chr2L, starts at 1 and spacing is 10bp.
Expand Down
8 changes: 0 additions & 8 deletions pybedtools/test/test_gzip_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,9 @@

import pybedtools
import gzip
from .tfuncs import test_tempdir


def setup_module():
if not os.path.exists(test_tempdir):
os.system("mkdir -p %s" % test_tempdir)
pybedtools.set_tempdir(test_tempdir)

def teardown_module():
if os.path.exists(test_tempdir):
os.system("rm -r %s" % test_tempdir)
pybedtools.cleanup()

def _make_temporary_gzip(bed_filename):
Expand Down
4 changes: 3 additions & 1 deletion pybedtools/test/test_helpers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import pybedtools
import sys
import os
from .tfuncs import testdir, test_tempdir
import tempfile
from .tfuncs import testdir
import pytest
from pathlib import Path

Expand Down Expand Up @@ -41,6 +42,7 @@ def test_cleanup():

# make a fake tempfile, not created during this pybedtools session
pybedtools.cleanup()
test_tempdir = os.path.abspath(tempfile.gettempdir())
testfn = Path(test_tempdir) / "pybedtools.TESTING.tmp"
testfn.parent.mkdir(parents=True, exist_ok=True)
testfn.touch()
Expand Down
9 changes: 0 additions & 9 deletions pybedtools/test/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,10 @@


testdir = os.path.dirname(__file__)
tempdir = os.path.join(os.path.abspath(testdir), "tmp")
unwriteable = "unwriteable"


def setup_module():
if not os.path.exists(tempdir):
os.system("mkdir -p %s" % tempdir)
pybedtools.set_tempdir(tempdir)


def teardown_module():
if os.path.exists(tempdir):
os.system("rm -r %s" % tempdir)
pybedtools.cleanup()


Expand Down
9 changes: 0 additions & 9 deletions pybedtools/test/test_iter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,8 @@
import os
import gzip
import pybedtools
from .tfuncs import test_tempdir

def setup_module():
if not os.path.exists(test_tempdir):
os.system("mkdir -p %s" % test_tempdir)
pybedtools.set_tempdir(test_tempdir)


def teardown_module():
if os.path.exists(test_tempdir):
os.system("rm -r %s" % test_tempdir)
pybedtools.cleanup()

yamltestdesc = ["test_cases.yaml"]
Expand Down
10 changes: 0 additions & 10 deletions pybedtools/test/tfuncs.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
import pytest
import pybedtools
import os

testdir = os.path.dirname(__file__)
test_tempdir = os.path.join(os.path.abspath(testdir), "tmp")
unwriteable = os.path.join(os.path.abspath(testdir), "unwriteable")


def setup_module():
if not os.path.exists(test_tempdir):
os.system("mkdir -p %s" % test_tempdir)
pybedtools.set_tempdir(test_tempdir)


def teardown_module():
if os.path.exists(test_tempdir):
os.system("rm -r %s" % test_tempdir)
pybedtools.cleanup()

0 comments on commit c1838a9

Please sign in to comment.