Run mainline tests only on posix systems where symlinks work.
This commit is contained in:
parent
f737486754
commit
be5da7c04b
2 changed files with 33 additions and 1 deletions
|
@ -15,6 +15,8 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import pytest
|
||||||
|
|
||||||
basedir = os.path.dirname(__file__)
|
basedir = os.path.dirname(__file__)
|
||||||
dosage_cmd = os.path.join(os.path.dirname(basedir), "dosage")
|
dosage_cmd = os.path.join(os.path.dirname(basedir), "dosage")
|
||||||
|
@ -37,3 +39,26 @@ def run_checked (cmd, ret_ok=(0,), **kwargs):
|
||||||
msg = "Command `%s' returned non-zero exit status %d" % (cmd, retcode)
|
msg = "Command `%s' returned non-zero exit status %d" % (cmd, retcode)
|
||||||
raise OSError(msg)
|
raise OSError(msg)
|
||||||
return retcode
|
return retcode
|
||||||
|
|
||||||
|
|
||||||
|
# Python 3.x renamed the function name attribute
|
||||||
|
if sys.version_info[0] > 2:
|
||||||
|
fnameattr = '__name__'
|
||||||
|
else:
|
||||||
|
fnameattr = 'func_name'
|
||||||
|
|
||||||
|
def _need_func(testfunc, name, description):
|
||||||
|
"""Decorator skipping test if given testfunc returns False."""
|
||||||
|
def check_func(func):
|
||||||
|
def newfunc(*args, **kwargs):
|
||||||
|
if not testfunc(name):
|
||||||
|
raise pytest.skip("%s %r is not available" % (description, name))
|
||||||
|
return func(*args, **kwargs)
|
||||||
|
setattr(newfunc, fnameattr, getattr(func, fnameattr))
|
||||||
|
return newfunc
|
||||||
|
return check_func
|
||||||
|
|
||||||
|
|
||||||
|
def needs_os(name):
|
||||||
|
"""Decorator skipping test if given operating system is not available."""
|
||||||
|
return _need_func(lambda x: os.name == x, name, 'operating system')
|
||||||
|
|
|
@ -17,7 +17,7 @@ import unittest
|
||||||
import sys
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
from . import dosage_cmd, mainline_cmd, run_checked
|
from . import dosage_cmd, mainline_cmd, run_checked, needs_os
|
||||||
|
|
||||||
|
|
||||||
def run_with_options(options, cmd=dosage_cmd):
|
def run_with_options(options, cmd=dosage_cmd):
|
||||||
|
@ -39,6 +39,7 @@ class TestDosage (unittest.TestCase):
|
||||||
for option in ("-l", "--list", "--singlelist"):
|
for option in ("-l", "--list", "--singlelist"):
|
||||||
run_with_options([option])
|
run_with_options([option])
|
||||||
|
|
||||||
|
@needs_os('posix')
|
||||||
def test_list_comics_mainline(self):
|
def test_list_comics_mainline(self):
|
||||||
for option in ("-l", "--list", "--singlelist"):
|
for option in ("-l", "--list", "--singlelist"):
|
||||||
run_with_options([option], cmd=mainline_cmd)
|
run_with_options([option], cmd=mainline_cmd)
|
||||||
|
@ -46,6 +47,7 @@ class TestDosage (unittest.TestCase):
|
||||||
def test_version(self):
|
def test_version(self):
|
||||||
run_with_options(["--version"])
|
run_with_options(["--version"])
|
||||||
|
|
||||||
|
@needs_os('posix')
|
||||||
def test_version_mainline(self):
|
def test_version_mainline(self):
|
||||||
run_with_options(["--version"], cmd=mainline_cmd)
|
run_with_options(["--version"], cmd=mainline_cmd)
|
||||||
|
|
||||||
|
@ -55,6 +57,7 @@ class TestDosage (unittest.TestCase):
|
||||||
# module help
|
# module help
|
||||||
run_with_options(["-m", "calvinandhobbes"])
|
run_with_options(["-m", "calvinandhobbes"])
|
||||||
|
|
||||||
|
@needs_os('posix')
|
||||||
def test_help_mainline(self):
|
def test_help_mainline(self):
|
||||||
for option in ("-h", "--help"):
|
for option in ("-h", "--help"):
|
||||||
run_with_options([option], cmd=mainline_cmd)
|
run_with_options([option], cmd=mainline_cmd)
|
||||||
|
@ -66,6 +69,7 @@ class TestDosage (unittest.TestCase):
|
||||||
self.assertRaises(OSError, run_with_options, ['--imadoofus'])
|
self.assertRaises(OSError, run_with_options, ['--imadoofus'])
|
||||||
self.assertRaises(OSError, run_with_options, ['Garfield'])
|
self.assertRaises(OSError, run_with_options, ['Garfield'])
|
||||||
|
|
||||||
|
@needs_os('posix')
|
||||||
def test_error_mainline(self):
|
def test_error_mainline(self):
|
||||||
self.assertRaises(OSError, run_with_options, [], mainline_cmd)
|
self.assertRaises(OSError, run_with_options, [], mainline_cmd)
|
||||||
self.assertRaises(OSError, run_with_options, ['--imadoofus'], mainline_cmd)
|
self.assertRaises(OSError, run_with_options, ['--imadoofus'], mainline_cmd)
|
||||||
|
@ -74,17 +78,20 @@ class TestDosage (unittest.TestCase):
|
||||||
def test_fetch_html(self):
|
def test_fetch_html(self):
|
||||||
run_with_options(["-n", "2", "-b", self.tmpdir, "-o", "html", "-o", "rss", "calvinandhobbes"])
|
run_with_options(["-n", "2", "-b", self.tmpdir, "-o", "html", "-o", "rss", "calvinandhobbes"])
|
||||||
|
|
||||||
|
@needs_os('posix')
|
||||||
def test_fetch_html_mainline(self):
|
def test_fetch_html_mainline(self):
|
||||||
run_with_options(["-n", "2", "-b", self.tmpdir, "-o", "html", "-o", "rss", "calvinandhobbes"], cmd=mainline_cmd)
|
run_with_options(["-n", "2", "-b", self.tmpdir, "-o", "html", "-o", "rss", "calvinandhobbes"], cmd=mainline_cmd)
|
||||||
|
|
||||||
def test_fetch_rss(self):
|
def test_fetch_rss(self):
|
||||||
run_with_options(["--numstrips", "2", "--baseurl", "bla", "--basepath", self.tmpdir, "--output", "rss", "--output", "html", "--adult", "sexyloser"])
|
run_with_options(["--numstrips", "2", "--baseurl", "bla", "--basepath", self.tmpdir, "--output", "rss", "--output", "html", "--adult", "sexyloser"])
|
||||||
|
|
||||||
|
@needs_os('posix')
|
||||||
def test_fetch_rss_mainline(self):
|
def test_fetch_rss_mainline(self):
|
||||||
run_with_options(["--numstrips", "2", "--baseurl", "bla", "--basepath", self.tmpdir, "--output", "rss", "--output", "html", "--adult", "sexyloser"], cmd=mainline_cmd)
|
run_with_options(["--numstrips", "2", "--baseurl", "bla", "--basepath", self.tmpdir, "--output", "rss", "--output", "html", "--adult", "sexyloser"], cmd=mainline_cmd)
|
||||||
|
|
||||||
def test_fetch_indexed(self):
|
def test_fetch_indexed(self):
|
||||||
run_with_options(["-n", "2", "-b", self.tmpdir, "calvinandhobbes:2012/02/02"])
|
run_with_options(["-n", "2", "-b", self.tmpdir, "calvinandhobbes:2012/02/02"])
|
||||||
|
|
||||||
|
@needs_os('posix')
|
||||||
def test_fetch_indexed_mainline(self):
|
def test_fetch_indexed_mainline(self):
|
||||||
run_with_options(["-n", "2", "-b", self.tmpdir, "calvinandhobbes:2012/02/02"], cmd=mainline_cmd)
|
run_with_options(["-n", "2", "-b", self.tmpdir, "calvinandhobbes:2012/02/02"], cmd=mainline_cmd)
|
||||||
|
|
Loading…
Reference in a new issue