From 19a0d51d89b640c04dc285067fc59b4a7fe9ca7f Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Mon, 17 Jun 2013 04:41:06 -0400 Subject: Use dosctrings in BeakerLib phase descriptions Phase names are now in the format: test-module-TestClass-test_method: First line of docstring https://fedorahosted.org/freeipa/ticket/3723 --- ipatests/beakerlib_plugin.py | 18 ++++++++++++++---- ipatests/test_integration/test_simple_replication.py | 7 +++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ipatests/beakerlib_plugin.py b/ipatests/beakerlib_plugin.py index 770fced49..8857a2844 100644 --- a/ipatests/beakerlib_plugin.py +++ b/ipatests/beakerlib_plugin.py @@ -121,8 +121,15 @@ class BeakerLibPlugin(Plugin): """ if not isinstance(context, type): return - message = 'Nose Test Class: %s' % context.__name__ - self.run_beakerlib_command(['rlPhaseStart', 'FAIL', message]) + try: + docstring = context.__doc__ + caption = docstring.strip().partition('\n')[0] + except AttributeError: + docstring = '' + caption = 'Nose class (no docstring)' + phase_name = "%s-%s: %s" % (context.__module__.replace('.', '-'), + context.__name__, caption) + self.run_beakerlib_command(['rlPhaseStart', 'FAIL', phase_name]) self._in_class_setup = True def stopContext(self, context): @@ -137,8 +144,11 @@ class BeakerLibPlugin(Plugin): if self._in_class_setup: self.collect_logs(test.context) self.log.info('Running test: %s', test.id()) - self.run_beakerlib_command(['rlPhaseStart', 'FAIL', - 'Nose test: %s' % test]) + caption = test.shortDescription() + if not caption: + caption = 'Nose method (no docstring)' + phase_name = "%s: %s" % (test.id().replace('.', '-'), caption) + self.run_beakerlib_command(['rlPhaseStart', 'FAIL', phase_name]) def stopTest(self, test): """End a test phase""" diff --git a/ipatests/test_integration/test_simple_replication.py b/ipatests/test_integration/test_simple_replication.py index a5d1bb208..8da59e5c5 100644 --- a/ipatests/test_integration/test_simple_replication.py +++ b/ipatests/test_integration/test_simple_replication.py @@ -23,10 +23,16 @@ from ipatests.test_integration.base import IntegrationTest class TestSimpleReplication(IntegrationTest): + """Simple replication test + + Install a server and a replica, then add an user on one host and ensure + it is also present on the other one. + """ num_replicas = 1 topology = 'star' def test_user_replication_to_replica(self): + """Test user replication master -> replica""" login = 'testuser1' self.master.run_command(['ipa', 'user-add', login, '--first', 'test', @@ -39,6 +45,7 @@ class TestSimpleReplication(IntegrationTest): assert 'User login: %s' % login in result.stdout_text def test_user_replication_to_master(self): + """Test user replication replica -> master""" login = 'testuser2' self.replicas[0].run_command(['ipa', 'user-add', login, '--first', 'test', -- cgit