Bug 1291796 - Minor fixes to harness unit tests; r=maja_zf

In test_marionette_runner.py, fix pytest warning raised when
importing TestManifest class directly in global namespace.

In test_marionette_arguments.py, improve readability by
shortening/changing some names and removing unnecessary
comments (not needed as code is self-explanatory).

MozReview-Commit-ID: GDzxlEqb7MB

--HG--
extra : rebase_source : 78927cae7f8ec011d2b398e3a1ce71174d7b028c
This commit is contained in:
Anjana Vakil 2016-08-26 15:52:29 +02:00
Родитель 6e249bab1e
Коммит 6aa106320d
2 изменённых файлов: 8 добавлений и 9 удалений

Просмотреть файл

@ -6,9 +6,9 @@ import pytest
from marionette.runtests import MarionetteArguments
@pytest.mark.parametrize("sock_timeout_value", ['A', '10', '1B-', '1C2', '44.35'])
def test_parse_arg_socket_timeout_with_multiple_values(sock_timeout_value):
argv = ['marionette', '--socket-timeout', sock_timeout_value]
@pytest.mark.parametrize("socket_timeout", ['A', '10', '1B-', '1C2', '44.35'])
def test_parse_arg_socket_timeout(socket_timeout):
argv = ['marionette', '--socket-timeout', socket_timeout]
parser = MarionetteArguments()
def _is_float_convertible(value):
@ -18,15 +18,13 @@ def test_parse_arg_socket_timeout_with_multiple_values(sock_timeout_value):
except:
return False
if not _is_float_convertible(sock_timeout_value):
# should raising exception, since sock_timeout must be convertible to float.
if not _is_float_convertible(socket_timeout):
with pytest.raises(SystemExit) as ex:
parser.parse_args(args=argv)
assert ex.value.code == 2
else:
# should pass without raising exception.
args = parser.parse_args(args=argv)
assert hasattr(args, 'socket_timeout') and args.socket_timeout == float(sock_timeout_value)
assert hasattr(args, 'socket_timeout') and args.socket_timeout == float(socket_timeout)
if __name__ == '__main__':

Просмотреть файл

@ -6,7 +6,7 @@ import pytest
from mock import Mock, patch, mock_open, sentinel, DEFAULT
from marionette.runtests import MarionetteTestRunner
from manifestparser import TestManifest
import manifestparser
@pytest.fixture
@ -95,7 +95,8 @@ def manifest_fixture(request):
self.filepath = "/path/to/fake/manifest.ini"
self.n_disabled = len([t for t in tests if 'disabled' in t])
self.n_enabled = len(tests) - self.n_disabled
mock_manifest = Mock(spec=TestManifest, active_tests=Mock(return_value=tests))
mock_manifest = Mock(spec=manifestparser.TestManifest,
active_tests=Mock(return_value=tests))
self.mock_manifest = Mock(return_value=mock_manifest)
self.__repr__ = lambda: "<ManifestFixture {}>".format(name)