1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
3
# Autopilot Functional Test Tool
4
# Copyright (C) 2012-2013 Canonical
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
from __future__ import absolute_import
23
from autopilot.testcase import AutopilotTestCase
24
from testtools.matchers import raises
27
class ApplicationSupportTests(AutopilotTestCase):
29
def test_launch_with_bad_types_raises_typeerror(self):
30
"""Calling launch_test_application with something other than a string must
33
self.assertThat(lambda: self.launch_test_application(1), raises(TypeError))
34
self.assertThat(lambda: self.launch_test_application(True), raises(TypeError))
35
self.assertThat(lambda: self.launch_test_application(1.0), raises(TypeError))
36
self.assertThat(lambda: self.launch_test_application(object()), raises(TypeError))
37
self.assertThat(lambda: self.launch_test_application(None), raises(TypeError))
38
self.assertThat(lambda: self.launch_test_application([]), raises(TypeError))
39
self.assertThat(lambda: self.launch_test_application((None,)), raises(TypeError))
41
def test_launch_raises_ValueError_on_unknown_kwargs(self):
42
"""launch_test_application must raise ValueError when given unknown
46
fn = lambda: self.launch_test_application('gedit', arg1=123, arg2='asd')
47
self.assertThat(fn, raises(ValueError("Unknown keyword arguments: 'arg1', 'arg2'.")))
49
def test_launch_raises_ValueError_on_unknown_kwargs_with_known(self):
50
"""launch_test_application must raise ValueError when given unknown
54
fn = lambda: self.launch_test_application('gedit', arg1=123, arg2='asd', launch_dir='/')
55
self.assertThat(fn, raises(ValueError("Unknown keyword arguments: 'arg1', 'arg2'.")))