From 365fd1780206eceaf79fab7e7dc518e0b8ce03fc Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Sun, 5 Jan 2014 14:26:46 +0100 Subject: [PATCH] Fix dosage tests --- tests/test_dosage.py | 48 +++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/tests/test_dosage.py b/tests/test_dosage.py index 4e7451d22..7b96b3ebb 100644 --- a/tests/test_dosage.py +++ b/tests/test_dosage.py @@ -28,39 +28,41 @@ def run_with_options(options, cmd=dosage_cmd): class TestDosage (unittest.TestCase): """Test the dosage commandline client.""" - def setUp(self): - # create a temporary directory for images - self.tmpdir = tempfile.mkdtemp() - - def tearDown(self): - shutil.rmtree(self.tmpdir) - - def test_list_comics(self): + def test_dosage(self): + # list comics for option in ("-l", "--list", "--singlelist"): run_with_options([option]) - - def test_version(self): + # display version run_with_options(["--version"]) - - def test_help(self): + # display help for option in ("-h", "--help"): run_with_options([option]) # module help run_with_options(["-m", "calvinandhobbes"]) - - def test_error(self): # no comics specified self.assertRaises(OSError, run_with_options, []) # unknown option self.assertRaises(OSError, run_with_options, ['--imadoofus']) # multiple comics match self.assertRaises(OSError, run_with_options, ['Garfield']) - - def test_fetch_html(self): - run_with_options(["-n", "2", "-v", "-b", self.tmpdir, "-o", "html", "-o", "rss", "calvinandhobbes"]) - - def test_fetch_rss(self): - run_with_options(["--numstrips", "2", "--baseurl", "bla", "--basepath", self.tmpdir, "--output", "rss", "--output", "html", "--adult", "sexyloser"]) - - def test_fetch_indexed(self): - run_with_options(["-n", "2", "-v", "-b", self.tmpdir, "calvinandhobbes:2012/02/02"]) + # create a temporary directory for images + tmpdir = tempfile.mkdtemp() + try: + # fetch html and rss + run_with_options(["-n", "2", "-v", "-b", tmpdir, "-o", "html", "-o", "rss", "calvinandhobbes"]) + finally: + shutil.rmtree(tmpdir) + # create a temporary directory for images + tmpdir = tempfile.mkdtemp() + try: + # fetch html and rss 2 + run_with_options(["--numstrips", "2", "--baseurl", "bla", "--basepath", tmpdir, "--output", "rss", "--output", "html", "--adult", "sexyloser"]) + finally: + shutil.rmtree(tmpdir) + # create a temporary directory for images + tmpdir = tempfile.mkdtemp() + try: + # fetch indexed + run_with_options(["-n", "2", "-v", "-b", tmpdir, "calvinandhobbes:2012/02/02"]) + finally: + shutil.rmtree(tmpdir)