346
345
if options.all and not has_actions(options):
347
346
parser.error("--all requires an action.")
350
fail_count, test_count = doctest.testmod()
351
sys.exit(os.EX_OK if fail_count == 0 else 1)
350
354
bus = dbus.SystemBus()
351
355
mandos_dbus_objc = bus.get_object(busname, server_path)
489
493
client.Approve(dbus.Boolean(False),
490
494
dbus_interface=client_interface)
493
class Test_milliseconds_to_string(unittest.TestCase):
495
self.assertEqual(milliseconds_to_string(93785000),
497
def test_no_days(self):
498
self.assertEqual(milliseconds_to_string(7385000), "02:03:05")
499
def test_all_zero(self):
500
self.assertEqual(milliseconds_to_string(0), "00:00:00")
501
def test_no_fractional_seconds(self):
502
self.assertEqual(milliseconds_to_string(400), "00:00:00")
503
self.assertEqual(milliseconds_to_string(900), "00:00:00")
504
self.assertEqual(milliseconds_to_string(1900), "00:00:01")
507
def should_only_run_tests():
508
parser = argparse.ArgumentParser(add_help=False)
509
parser.add_argument("--check", action='store_true')
510
args, unknown_args = parser.parse_known_args()
511
run_tests = args.check
513
# Remove --check argument from sys.argv
514
sys.argv[1:] = unknown_args
517
# Add all tests from doctest strings
518
def load_tests(loader, tests, none):
520
tests.addTests(doctest.DocTestSuite())
523
497
if __name__ == "__main__":
524
if should_only_run_tests():
525
# Call using ./tdd-python-script --check [--verbose]