1 # test_run.py -- Tests for selftest.run
2 # Copyright (C) 2012 Jelmer Vernooij <jelmer@samba.org>
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; version 3
7 # of the License or (at your option) any later version of
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 """Tests for selftest.run."""
24 from selftest.run import (
26 expand_environment_strings,
30 from selftest.tests import TestCase
33 class ExpandEnvironmentStringsTests(TestCase):
35 def test_no_vars(self):
36 self.assertEquals("foo bar", expand_environment_strings("foo bar", {}))
38 def test_simple(self):
39 self.assertEquals("foo bar",
40 expand_environment_strings("foo $BLA", {"BLA": "bar"}))
42 def test_unknown(self):
43 self.assertEquals("foo $BLA",
44 expand_environment_strings("foo $BLA", {}))
47 class ExpandCommandListTests(TestCase):
49 def test_no_list(self):
50 self.assertIs(None, expand_command_list("test bla"))
53 self.assertEquals("test --list", expand_command_list("test $LISTOPT"))
56 class ExpandCommandRunTests(TestCase):
58 def test_idlist(self):
59 self.assertEquals(("test foo bar", None),
60 expand_command_run("test", False, True, subtests=["foo", "bar"]))
62 def test_idlist_all(self):
63 self.assertEquals(("test", None),
64 expand_command_run("test", False, True))
66 def test_loadlist(self):
67 (cmd, tmpf) = expand_command_run("test $LOADLIST", True, False,
68 subtests=["foo", "bar"])
69 self.addCleanup(os.remove, tmpf)
72 self.assertEquals(f.read(), "foo\nbar\n")
75 self.assertEquals("test --load-list=%s" % tmpf, cmd)
77 def test_loadlist_all(self):
78 self.assertEquals(("test ", None),
79 expand_command_run("test $LOADLIST", True, False))