Port autopkgtests to python3, taken from Ubuntu, thanks to them and Dimitri John Ledkov (Closes: #937169)
This commit is contained in:
parent
5c60ced7db
commit
dcb5203681
5 changed files with 63 additions and 56 deletions
18
debian/tests/test-nut.py
vendored
18
debian/tests/test-nut.py
vendored
|
|
@ -75,7 +75,7 @@ try:
|
|||
except ImportError:
|
||||
class PrivateNutTest(object):
|
||||
'''Empty class'''
|
||||
print >>sys.stdout, "Skipping private tests"
|
||||
print("Skipping private tests")
|
||||
|
||||
|
||||
class NutTestCommon(testlib.TestlibCase):
|
||||
|
|
@ -161,7 +161,7 @@ FINALDELAY 0
|
|||
|
||||
testlib.create_fill(self.notifyscript, '''
|
||||
#! /bin/bash
|
||||
echo "$*" > ''' + self.notifylog + '\n', mode=0755)
|
||||
echo "$*" > ''' + self.notifylog + '\n', mode=0o755)
|
||||
|
||||
# dummy-ups absolutely needs a data file, even if empty
|
||||
testlib.config_replace('/etc/nut/dummy.dev', '''
|
||||
|
|
@ -230,7 +230,7 @@ UPSMON_OPTIONS=""
|
|||
rc, report = testlib.cmd([self.initscript, 'start'])
|
||||
expected = 0
|
||||
result = 'Got exit code %d, expected %d\n' % (rc, expected)
|
||||
self.assertEquals(expected, rc, result + report)
|
||||
self.assertEqual(expected, rc, result + report)
|
||||
time.sleep(2)
|
||||
|
||||
def _stop(self):
|
||||
|
|
@ -238,14 +238,14 @@ UPSMON_OPTIONS=""
|
|||
rc, report = testlib.cmd([self.initscript, 'stop'])
|
||||
expected = 0
|
||||
result = 'Got exit code %d, expected %d\n' % (rc, expected)
|
||||
self.assertEquals(expected, rc, result + report)
|
||||
self.assertEqual(expected, rc, result + report)
|
||||
|
||||
def _reload(self):
|
||||
'''Reload NUT'''
|
||||
rc, report = testlib.cmd([self.initscript, 'force-reload'])
|
||||
expected = 0
|
||||
result = 'Got exit code %d, expected %d\n' % (rc, expected)
|
||||
self.assertEquals(expected, rc, result + report)
|
||||
self.assertEqual(expected, rc, result + report)
|
||||
|
||||
def _restart(self):
|
||||
'''Restart NUT'''
|
||||
|
|
@ -261,7 +261,7 @@ UPSMON_OPTIONS=""
|
|||
self._skipped("init script does not support status command")
|
||||
expected = 1
|
||||
result = 'Got exit code %d, expected %d\n' % (rc, expected)
|
||||
self.assertEquals(expected, rc, result + report)
|
||||
self.assertEqual(expected, rc, result + report)
|
||||
|
||||
def _testDaemons(self, daemons):
|
||||
'''Daemons running'''
|
||||
|
|
@ -379,7 +379,7 @@ printf '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\n' | nc -q 1 127.0.0.1
|
|||
sleep 1
|
||||
dd if=/dev/urandom count=64 | nc -q 1 127.0.0.1 3493
|
||||
'''
|
||||
testlib.create_fill(script, contents, mode=0755)
|
||||
testlib.create_fill(script, contents, mode=0o755)
|
||||
rc, report = testlib.cmd([script])
|
||||
|
||||
# It should not have crashed. Let's see if it did
|
||||
|
|
@ -414,9 +414,9 @@ if __name__ == '__main__':
|
|||
# suite.addTest(unittest.TestLoader().loadTestsFromTestCase(MyPrivateTest))
|
||||
|
||||
else:
|
||||
print '''Usage:
|
||||
print('''Usage:
|
||||
test-nut.py [-v] basic tests
|
||||
'''
|
||||
''')
|
||||
sys.exit(1)
|
||||
rc = unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
if not rc.wasSuccessful():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue