Merge lp:~veebers/autopilot/fix_too_many_vids_1189655 into lp:autopilot

Proposed by Christopher Lee
Status: Merged
Approved by: Chris Gagnon
Approved revision: 242
Merged at revision: 241
Proposed branch: lp:~veebers/autopilot/fix_too_many_vids_1189655
Merge into: lp:autopilot
Diff against target: 61 lines (+31/-2)
2 files modified
autopilot/globals.py (+4/-1)
autopilot/tests/functional/test_autopilot_functional.py (+27/-1)
To merge this branch: bzr merge lp:~veebers/autopilot/fix_too_many_vids_1189655
Reviewer Review Type Date Requested Status
Chris Gagnon (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+168590@code.launchpad.net

Commit message

Added an extra check so that a 'failing' test wasn't recorded if it was in fact a skipping test.

Description of the change

Added an extra check so that a 'failing' test wasn't recorded if it was in fact a skipping test.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Chris Gagnon (chris.gagnon) wrote :

Can you add a test for the new if statement?

review: Needs Fixing
242. By Christopher Lee

Added missing test for video recording and skipped tests

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Chris Gagnon (chris.gagnon) wrote :

Looks good, thanks for writing the test

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'autopilot/globals.py'
2--- autopilot/globals.py 2013-05-30 12:00:24 +0000
3+++ autopilot/globals.py 2013-06-12 00:43:25 +0000
4@@ -163,7 +163,10 @@
5
6 def _on_test_failed(self, ex_info):
7 """Called when a test fails."""
8- self._test_passed = False
9+ from unittest.case import SkipTest
10+ failure_class_type = ex_info[0]
11+ if failure_class_type is not SkipTest:
12+ self._test_passed = False
13
14
15 _video_logger = _VideoLogger()
16
17=== modified file 'autopilot/tests/functional/test_autopilot_functional.py'
18--- autopilot/tests/functional/test_autopilot_functional.py 2013-05-30 21:35:13 +0000
19+++ autopilot/tests/functional/test_autopilot_functional.py 2013-06-12 00:43:25 +0000
20@@ -466,7 +466,7 @@
21 if should_delete:
22 self.addCleanup(remove_if_exists, ap_dir)
23 else:
24- self.addCleanup(remove_if_exists,
25+ self.addCleanup(remove_if_exists,
26 '%s/tests.test_simple.SimpleTest.test_simple.ogv' % (ap_dir))
27
28 code, output, error = self.run_autopilot(["run", "-r", "-rd", video_dir, "tests"])
29@@ -526,6 +526,32 @@
30 self.assertFalse(os.path.exists(
31 '/tmp/autopilot/tests.test_simple.SimpleTest.test_simple.ogv'))
32
33+ def test_no_videos_saved_for_skipped_test(self):
34+ """Videos must not be saved if the test has been skipped (not
35+ failed).
36+
37+ """
38+ self.create_test_file("test_simple.py", dedent("""\
39+
40+ from autopilot.testcase import AutopilotTestCase
41+ from time import sleep
42+
43+ class SimpleTest(AutopilotTestCase):
44+
45+ def test_simple(self):
46+ sleep(1)
47+ self.skip("Skipping Test")
48+ """
49+ ))
50+
51+ video_file_path = '/tmp/autopilot/tests.test_simple.SimpleTest.test_simple.ogv'
52+ self.addCleanup(remove_if_exists, video_file_path)
53+
54+ code, output, error = self.run_autopilot(["run", "-r", "tests"])
55+
56+ self.assertThat(code, Equals(0))
57+ self.assertThat(os.path.exists(video_file_path), Equals(False))
58+
59 def test_runs_with_import_errors_fail(self):
60 """Import errors inside a test must be considered a test failure."""
61 self.create_test_file('test_simple.py', dedent("""\

Subscribers

People subscribed via source and target branches