From fc92a206b0a95dec76875fff47b7cb8e08b4628f Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Tue, 28 Jun 2011 20:21:07 +0100 Subject: Load tests from files instead of including them in the code. --- systest | 47 +---------------------------------------------- 1 file changed, 1 insertion(+), 46 deletions(-) (limited to 'systest') diff --git a/systest b/systest index bf650b5..d6fed0c 100755 --- a/systest +++ b/systest @@ -9,46 +9,9 @@ import unittest import systest -class DebianBaseTests(systest.TestCase): - - def test_only_ssh_port(self): - out = self.hostcmd(['nmap', self.settings['target']]) - ports = [line.split()[0] - for line in out.splitlines() - if ' open ' in line] - self.assertEqual(ports, ['22/tcp']) - - def test_ssh_login(self): - user = self.settings['user'] - out = self.hostcmd(['ssh', '-l', user, self.settings['target'], 'id']) - self.assertMatches(r'^uid=1000\(%s\)' % user, out) - - def test_simple_dns_lookup(self): - out = self.targetcmd(['host', 'www.debian.org']) - self.assert_('www.debian.org' in out) - - def test_ping_localhost(self): - self.targetcmd(['ping', '-c1', 'localhost']) - - def test_ping6_localhost(self): - self.targetcmd(['ping6', '-c1', 'ip6-localhost']) - - def test_cat(self): - out = self.targetcmd(['cat'], stdin='foo') - self.assertEqual(out, 'foo') - -# def test_sudo(self): -# out = self.targetcmd(['sudo', 'id'], -# stdin=self.settings['user-password']) -# self.assertMatches(r'^uid=0\(root\)', out) - - - class SystemTest(cliapp.Application): def add_settings(self): - self.settings.boolean(['verbose', 'v'], - 'print names of tests when run') self.settings.string(['target'], 'target domain name or IP address') self.settings.string(['user'], 'user on target') self.settings.string(['user-password'], 'password for target user') @@ -56,7 +19,7 @@ class SystemTest(cliapp.Application): def process_args(self, args): loader = unittest.defaultTestLoader loader.suiteClass = self.create_suite - suite = loader.loadTestsFromTestCase(DebianBaseTests) + suite = loader.loadTestsFromNames(args) unittest.TextTestRunner().run(suite) def create_suite(self, tests): @@ -65,14 +28,6 @@ class SystemTest(cliapp.Application): suite = unittest.TestSuite(tests) return suite - def mangle(self, testname): - return 'test_' + testname.replace('-', '_') - - def unmangle(self, methodname): - assert methodname.startswith('test_') - methodname = methodname[len('test_'):] - return methodname.replace('_', '-') - if __name__ == '__main__': SystemTest().run() -- cgit v1.2.1