Permalink
Browse files

Merge pull request #307 from ifreecarve/2013-03-30_copy_pastable_names

Give tests copy-pastable identifiers in nose testing
  • Loading branch information...
2 parents 2d1f342 + e77dd6f commit 43b4a8af68207bc3f1b9106f56013e73b93c1367 @daf daf committed Apr 1, 2013
Showing with 23 additions and 0 deletions.
  1. +12 −0 pyon/util/int_test.py
  2. +11 −0 pyon/util/unit_test.py
View
@@ -45,6 +45,18 @@ class IonIntegrationTestCase(unittest.TestCase):
def shortDescription(self):
return None
+ # override __str__ and __repr__ behavior to show a copy-pastable nosetest name for ion tests
+ # ion.module:TestClassName.test_function_name
+ def __repr__(self):
+ name = self.id()
+ name = name.split('.')
+ if name[0] not in ["ion", "pyon"]:
+ return "%s (%s)" % (name[-1], '.'.join(name[:-1]))
+ else:
+ return "%s ( %s )" % (name[-1], '.'.join(name[:-2]) + ":" + '.'.join(name[-2:]))
+ __str__ = __repr__
+
+
def run(self, result=None):
unittest.TestCase.run(self, result)
View
@@ -35,6 +35,17 @@ class PyonTestCase(unittest.TestCase):
def shortDescription(self):
return None
+ # override __str__ and __repr__ behavior to show a copy-pastable nosetest name for ion tests
+ # ion.module:TestClassName.test_function_name
+ def __repr__(self):
+ name = self.id()
+ name = name.split('.')
+ if name[0] not in ["ion", "pyon"]:
+ return "%s (%s)" % (name[-1], '.'.join(name[:-1]))
+ else:
+ return "%s ( %s )" % (name[-1], '.'.join(name[:-2]) + ":" + '.'.join(name[-2:]))
+ __str__ = __repr__
+
def _create_IonObject_mock(self, name):
mock_ionobj = Mock(name='IonObject')
def side_effect(_def, _dict=None, **kwargs):

0 comments on commit 43b4a8a

Please sign in to comment.