Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
PRESUBMIT_test_mocks.py
Go to the documentation of this file.
1
# Copyright 2020 The PDFium Authors
2
# Use of this source code is governed by a BSD-style license that can be
3
# found in the LICENSE file.
4
5
import
re
6
7
8
class
MockInputApi
(object):
9
"""Mock class for the InputApi class.
10
11
This class can be used for unittests for presubmit by initializing the files
12
attribute as the list of changed files.
13
"""
14
15
def
__init__
(self):
16
self.
files
= []
17
self.
re
= re
18
19
def
AffectedFiles
(self, file_filter=None, include_deletes=False):
20
# pylint: disable=unused-argument
21
return
self.
files
22
23
24
class
MockOutputApi
(object):
25
"""Mock class for the OutputApi class.
26
27
An instance of this class can be passed to presubmit unittests for outputting
28
various types of results.
29
"""
30
31
class
PresubmitResult
(object):
32
33
def
__init__
(self, message, items=None, long_text=''):
34
self.
message
= message
35
self.
items
= items
36
self.
long_text
= long_text
37
38
def
__repr__
(self):
39
return
self.
message
40
41
class
PresubmitError
(
PresubmitResult
):
42
43
def
__init__
(self, message, items=None, long_text=''):
44
MockOutputApi.PresubmitResult.__init__(self, message, items, long_text)
45
self.
type
=
'error'
46
47
class
PresubmitPromptWarning
(
PresubmitResult
):
48
49
def
__init__
(self, message, items=None, long_text=''):
50
MockOutputApi.PresubmitResult.__init__(self, message, items, long_text)
51
self.
type
=
'warning'
52
53
54
class
MockFile
(object):
55
"""Mock class for the File class.
56
57
This class can be used to form the mock list of changed files in
58
MockInputApi for presubmit unittests.
59
"""
60
61
def
__init__
(self,
62
local_path,
63
new_contents=None,
64
old_contents=None,
65
action='A'):
66
self.
_local_path
= local_path
67
if
new_contents
is
None
:
68
new_contents = []
69
self.
_new_contents
= new_contents
70
self.
_changed_contents
= [(i + 1, l)
for
i, l
in
enumerate(new_contents)]
71
self.
_action
= action
72
self.
_old_contents
= old_contents
73
74
def
ChangedContents
(self):
75
return
self.
_changed_contents
76
77
def
LocalPath
(self):
78
return
self.
_local_path
PRESUBMIT_test_mocks.MockFile
Definition
PRESUBMIT_test_mocks.py:54
PRESUBMIT_test_mocks.MockFile.ChangedContents
ChangedContents(self)
Definition
PRESUBMIT_test_mocks.py:74
PRESUBMIT_test_mocks.MockFile.__init__
__init__(self, local_path, new_contents=None, old_contents=None, action='A')
Definition
PRESUBMIT_test_mocks.py:65
PRESUBMIT_test_mocks.MockFile.LocalPath
LocalPath(self)
Definition
PRESUBMIT_test_mocks.py:77
PRESUBMIT_test_mocks.MockFile._local_path
_local_path
Definition
PRESUBMIT_test_mocks.py:66
PRESUBMIT_test_mocks.MockFile._new_contents
_new_contents
Definition
PRESUBMIT_test_mocks.py:69
PRESUBMIT_test_mocks.MockFile._action
_action
Definition
PRESUBMIT_test_mocks.py:71
PRESUBMIT_test_mocks.MockFile._changed_contents
list _changed_contents
Definition
PRESUBMIT_test_mocks.py:70
PRESUBMIT_test_mocks.MockFile._old_contents
_old_contents
Definition
PRESUBMIT_test_mocks.py:72
PRESUBMIT_test_mocks.MockInputApi
Definition
PRESUBMIT_test_mocks.py:8
PRESUBMIT_test_mocks.MockInputApi.files
list files
Definition
PRESUBMIT_test_mocks.py:16
PRESUBMIT_test_mocks.MockInputApi.re
re
Definition
PRESUBMIT_test_mocks.py:17
PRESUBMIT_test_mocks.MockInputApi.__init__
__init__(self)
Definition
PRESUBMIT_test_mocks.py:15
PRESUBMIT_test_mocks.MockInputApi.AffectedFiles
AffectedFiles(self, file_filter=None, include_deletes=False)
Definition
PRESUBMIT_test_mocks.py:19
PRESUBMIT_test_mocks.MockOutputApi.PresubmitError
Definition
PRESUBMIT_test_mocks.py:41
PRESUBMIT_test_mocks.MockOutputApi.PresubmitError.__init__
__init__(self, message, items=None, long_text='')
Definition
PRESUBMIT_test_mocks.py:43
PRESUBMIT_test_mocks.MockOutputApi.PresubmitError.type
str type
Definition
PRESUBMIT_test_mocks.py:45
PRESUBMIT_test_mocks.MockOutputApi.PresubmitPromptWarning
Definition
PRESUBMIT_test_mocks.py:47
PRESUBMIT_test_mocks.MockOutputApi.PresubmitPromptWarning.__init__
__init__(self, message, items=None, long_text='')
Definition
PRESUBMIT_test_mocks.py:49
PRESUBMIT_test_mocks.MockOutputApi.PresubmitPromptWarning.type
str type
Definition
PRESUBMIT_test_mocks.py:51
PRESUBMIT_test_mocks.MockOutputApi.PresubmitResult
Definition
PRESUBMIT_test_mocks.py:31
PRESUBMIT_test_mocks.MockOutputApi.PresubmitResult.__init__
__init__(self, message, items=None, long_text='')
Definition
PRESUBMIT_test_mocks.py:33
PRESUBMIT_test_mocks.MockOutputApi.PresubmitResult.__repr__
__repr__(self)
Definition
PRESUBMIT_test_mocks.py:38
PRESUBMIT_test_mocks.MockOutputApi.PresubmitResult.long_text
long_text
Definition
PRESUBMIT_test_mocks.py:36
PRESUBMIT_test_mocks.MockOutputApi.PresubmitResult.message
message
Definition
PRESUBMIT_test_mocks.py:34
PRESUBMIT_test_mocks.MockOutputApi.PresubmitResult.items
items
Definition
PRESUBMIT_test_mocks.py:35
PRESUBMIT_test_mocks.MockOutputApi
Definition
PRESUBMIT_test_mocks.py:24
qtwebengine
src
3rdparty
chromium
third_party
pdfium
PRESUBMIT_test_mocks.py
Generated on Thu Nov 14 2024 01:10:18 for Qt by
1.12.0