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

Proposed by Christopher Lee
Status: Merged
Approved by: Thomi Richards
Approved revision: 349
Merged at revision: 345
Proposed branch: lp:~veebers/autopilot/update_functional_tests_for_py3
Merge into: lp:autopilot
Diff against target: 114 lines (+23/-17)
3 files modified
autopilot/tests/functional/__init__.py (+3/-8)
autopilot/tests/functional/test_autopilot_functional.py (+19/-8)
autopilot/tests/functional/test_dbus_query.py (+1/-1)
To merge this branch: bzr merge lp:~veebers/autopilot/update_functional_tests_for_py3
Reviewer Review Type Date Requested Status
Thomi Richards (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+189197@code.launchpad.net

Commit message

Update the autopilot funcational tests so they work under python 3.

Description of the change

Update the autopilot funcational tests so they work under python 3 (now that we can use tox to run under py33).

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
349. By Christopher Lee

Better/more specific checking of error output.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'autopilot/tests/functional/__init__.py'
--- autopilot/tests/functional/__init__.py 2013-09-17 18:50:07 +0000
+++ autopilot/tests/functional/__init__.py 2013-10-04 01:19:57 +0000
@@ -116,6 +116,7 @@
116 env=environ,116 env=environ,
117 stdout=subprocess.PIPE,117 stdout=subprocess.PIPE,
118 stderr=subprocess.PIPE,118 stderr=subprocess.PIPE,
119 universal_newlines=True,
119 )120 )
120121
121 stdout, stderr = process.communicate()122 stdout, stderr = process.communicate()
@@ -124,17 +125,11 @@
124 self.addDetail('retcode', text_content(str(retcode)))125 self.addDetail('retcode', text_content(str(retcode)))
125 self.addDetail(126 self.addDetail(
126 'stdout',127 'stdout',
127 Content(128 text_content(stdout)
128 ContentType('text', 'plain', {'charset': 'iso-8859-1'}),
129 lambda: [stdout]
130 )
131 )129 )
132 self.addDetail(130 self.addDetail(
133 'stderr',131 'stderr',
134 Content(132 text_content(stderr)
135 ContentType('text', 'plain', {'charset': 'iso-8859-1'}),
136 lambda: [stderr]
137 )
138 )133 )
139134
140 return (retcode, stdout, stderr)135 return (retcode, stdout, stderr)
141136
=== modified file 'autopilot/tests/functional/test_autopilot_functional.py'
--- autopilot/tests/functional/test_autopilot_functional.py 2013-09-25 02:23:02 +0000
+++ autopilot/tests/functional/test_autopilot_functional.py 2013-10-04 01:19:57 +0000
@@ -23,6 +23,7 @@
23from codecs import open23from codecs import open
24import os24import os
25import os.path25import os.path
26import re
26from tempfile import mktemp27from tempfile import mktemp
27from testtools.matchers import Contains, Equals, MatchesRegex, Not28from testtools.matchers import Contains, Equals, MatchesRegex, Not
28from textwrap import dedent29from textwrap import dedent
@@ -119,10 +120,15 @@
119 """)120 """)
120 )121 )
121 code, output, error = self.run_autopilot_list()122 code, output, error = self.run_autopilot_list()
122 expected_output = '''ImportError: No module named asdjkhdfjgsdhfjhsd'''
123 self.assertThat(code, Equals(0))123 self.assertThat(code, Equals(0))
124 self.assertThat(error, Equals(''))124 self.assertThat(error, Equals(''))
125 self.assertThat(output, Contains(expected_output))125 self.assertThat(
126 output,
127 MatchesRegex(
128 ".*ImportError: No module named [']?asdjkhdfjgsdhfjhsd[']?.*",
129 re.DOTALL
130 )
131 )
126132
127 def test_list_tests_with_syntax_error(self):133 def test_list_tests_with_syntax_error(self):
128 self.create_test_file(134 self.create_test_file(
@@ -500,11 +506,15 @@
500506
501 code, output, error = self.run_autopilot(["run", "tests"])507 code, output, error = self.run_autopilot(["run", "tests"])
502508
503 expected_error = 'ImportError: No module named asdjkhdfjgsdhfjhsd'
504
505 self.assertThat(code, Equals(1))509 self.assertThat(code, Equals(1))
506 self.assertThat(error, Equals(''))510 self.assertThat(error, Equals(''))
507 self.assertThat(output, Contains(expected_error))511 self.assertThat(
512 output,
513 MatchesRegex(
514 ".*ImportError: No module named [']?asdjkhdfjgsdhfjhsd[']?.*",
515 re.DOTALL
516 )
517 )
508 self.assertThat(output, Contains("FAILED (failures=1)"))518 self.assertThat(output, Contains("FAILED (failures=1)"))
509519
510 def test_runs_with_syntax_errors_fail(self):520 def test_runs_with_syntax_errors_fail(self):
@@ -825,7 +835,7 @@
825 class SimpleTest(AutopilotTestCase):835 class SimpleTest(AutopilotTestCase):
826836
827 def test_simple(self):837 def test_simple(self):
828 self.assertTrue()838 raise RuntimeError("Intentionally fail test.")
829 """)839 """)
830 )840 )
831841
@@ -837,8 +847,9 @@
837 error, Contains("ERROR: tests.test_simple.SimpleTest.test_simple"))847 error, Contains("ERROR: tests.test_simple.SimpleTest.test_simple"))
838 self.assertThat(error, Contains("traceback:"))848 self.assertThat(error, Contains("traceback:"))
839 self.assertThat(849 self.assertThat(
840 error, Contains("TypeError: assertTrue() takes at least 2 "850 error,
841 "arguments (1 given)"))851 Contains("RuntimeError: Intentionally fail test.")
852 )
842853
843 def test_verbose_flag_shows_failure(self):854 def test_verbose_flag_shows_failure(self):
844 """Verbose log must indicate a test failure with a traceback (xml855 """Verbose log must indicate a test failure with a traceback (xml
845856
=== modified file 'autopilot/tests/functional/test_dbus_query.py'
--- autopilot/tests/functional/test_dbus_query.py 2013-09-26 21:29:46 +0000
+++ autopilot/tests/functional/test_dbus_query.py 2013-10-04 01:19:57 +0000
@@ -157,7 +157,7 @@
157 match_fn = lambda: app.select_single(title="Non-existant object")157 match_fn = lambda: app.select_single(title="Non-existant object")
158 self.assertThat(158 self.assertThat(
159 match_fn,159 match_fn,
160 raises(StateNotFoundError(title="Non-existant object"))160 raises(StateNotFoundError('*', title="Non-existant object"))
161 )161 )
162162
163 def test_select_single_returning_multiple_raises(self):163 def test_select_single_returning_multiple_raises(self):

Subscribers

People subscribed via source and target branches