diff options
| author | Robert Collins <robertc@robertcollins.net> | 2009-07-20 18:13:55 +1000 |
|---|---|---|
| committer | Robert Collins <robertc@robertcollins.net> | 2009-07-20 18:13:55 +1000 |
| commit | 0dc614b47e7ec1b191cfd27ea65d2526b8fde45e (patch) | |
| tree | 03320f2e2597572be6d2392a2826a1e018255e82 /python/subunit/__init__.py | |
| parent | 57f483adeb597e93b9af7afba6ee10bf7af72c2e (diff) | |
| download | subunit-git-0dc614b47e7ec1b191cfd27ea65d2526b8fde45e.tar.gz | |
Teach python to call TestResult.time on time: tags.
Diffstat (limited to 'python/subunit/__init__.py')
| -rw-r--r-- | python/subunit/__init__.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py index fb6c83e..1a20dab 100644 --- a/python/subunit/__init__.py +++ b/python/subunit/__init__.py @@ -17,11 +17,13 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +import calendar import os +import re from StringIO import StringIO import subprocess import sys -import re +import time import unittest def test_suite(): @@ -207,6 +209,14 @@ class TestProtocolServer(object): update_tags.update(new_tags) update_tags.difference_update(gone_tags) + def _handleTime(self, offset, line): + # Accept it, but do not do anything with it yet. + event_time = time.strptime(line[offset:-1], "%Y-%m-%d %H:%M:%SZ") + time_seconds = calendar.timegm(event_time) + time_method = getattr(self.client, 'time', None) + if callable(time_method): + time_method(time_seconds) + def lineReceived(self, line): """Call the appropriate local method for the received line.""" if line == "]\n": @@ -236,8 +246,7 @@ class TestProtocolServer(object): elif cmd in ('tags',): self._handleTags(offset, line) elif cmd in ('time',): - # Accept it, but do not do anything with it yet. - pass + self._handleTime(offset, line) elif cmd == 'xfail': self._addExpectedFail(offset, line) else: |
