Skip to content

Commit 2548875

Browse files
theotherjimmyadbridge
authored andcommitted
Linting and correcting comments
1 parent 8bd92c8 commit 2548875

File tree

4 files changed

+58
-33
lines changed

4 files changed

+58
-33
lines changed

tools/test/config/config_test.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
mbed SDK
3-
Copyright (c) 2011-2016 ARM Limited
3+
Copyright (c) 2011-2017 ARM Limited
44
55
Licensed under the Apache License, Version 2.0 (the "License");
66
you may not use this file except in compliance with the License.
@@ -27,8 +27,12 @@
2727
from tools.targets import set_targets_json_location, Target, TARGET_NAMES
2828
from tools.config import ConfigException, Config
2929

30-
# Compare the output of config against a dictionary of known good results
3130
def compare_config(cfg, expected):
31+
"""Compare the output of config against a dictionary of known good results
32+
33+
:param cfg: the configuration to check
34+
:param expected: what to expect in that config
35+
"""
3236
try:
3337
for k in cfg:
3438
if cfg[k].value != expected[k]:
@@ -41,16 +45,28 @@ def compare_config(cfg, expected):
4145
return ""
4246

4347
def data_path(path):
48+
"""The expected data file for a particular test
49+
50+
:param path: the path to the test
51+
"""
4452
return join(path, "test_data.json")
4553

4654
def is_test(path):
55+
"""Does a directory represent a test?
56+
57+
:param path: the path to the test
58+
"""
4759
return isfile(data_path(path))
4860

4961
root_dir = abspath(dirname(__file__))
5062

5163
@pytest.mark.parametrize("name", filter(lambda d: is_test(join(root_dir, d)),
52-
os.listdir(root_dir)))
64+
os.listdir(root_dir)))
5365
def test_config(name):
66+
"""Run a particular configuration test
67+
68+
:param name: test name (same as directory name)
69+
"""
5470
test_dir = join(root_dir, name)
5571
test_data = json.load(open(data_path(test_dir)))
5672
targets_json = os.path.join(test_dir, "targets.json")
@@ -81,9 +97,7 @@ def test_init_app_config(target):
8197
"""
8298
Test that the initialisation correctly uses app_config
8399
84-
:param mock_json_file_to_dict: mock of function json_file_to_dict
85-
:param _: mock of function _process_config_and_overrides (not tested)
86-
:return:
100+
:param target: The target to use
87101
"""
88102
set_targets_json_location()
89103
with patch.object(Config, '_process_config_and_overrides'),\
@@ -103,9 +117,7 @@ def test_init_no_app_config(target):
103117
"""
104118
Test that the initialisation works without app config
105119
106-
:param mock_json_file_to_dict: mock of function json_file_to_dict
107-
:param _: patch of function _process_config_and_overrides (not tested)
108-
:return:
120+
:param target: The target to use
109121
"""
110122
set_targets_json_location()
111123
with patch.object(Config, '_process_config_and_overrides'),\
@@ -122,9 +134,7 @@ def test_init_no_app_config_with_dir(target):
122134
Test that the initialisation works without app config and with a
123135
specified top level directory
124136
125-
:param mock_json_file_to_dict: mock of function json_file_to_dict
126-
:param _: patch of function _process_config_and_overrides (not tested)
127-
:return:
137+
:param target: The target to use
128138
"""
129139
set_targets_json_location()
130140
with patch.object(Config, '_process_config_and_overrides'),\
@@ -149,9 +159,7 @@ def test_init_override_app_config(target):
149159
Test that the initialisation uses app_config instead of top_level_dir
150160
when both are specified
151161
152-
:param mock_json_file_to_dict: mock of function json_file_to_dict
153-
:param _: patch of function _process_config_and_overrides (not tested)
154-
:return:
162+
:param target: The target to use
155163
"""
156164
set_targets_json_location()
157165
with patch.object(Config, '_process_config_and_overrides'),\

tools/test/memap/memap_test.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
mbed SDK
3-
Copyright (c) 2016 ARM Limited
3+
Copyright (c) 2017 ARM Limited
44
55
Licensed under the Apache License, Version 2.0 (the "License");
66
you may not use this file except in compliance with the License.
@@ -60,7 +60,7 @@ def memap_parser():
6060
".flash_config":0,
6161
"unknown":0,
6262
"OUTPUT":0,
63-
},
63+
},
6464
"[lib]/libc.a/lib_a-printf.o": {
6565
".text": 4,
6666
".data": 5,
@@ -84,7 +84,7 @@ def memap_parser():
8484
".flash_config":0,
8585
"unknown":0,
8686
"OUTPUT":0,
87-
},
87+
},
8888
"main.o": {
8989
".text": 7,
9090
".data": 8,
@@ -108,7 +108,7 @@ def memap_parser():
108108
".flash_config":0,
109109
"unknown":0,
110110
"OUTPUT":0,
111-
},
111+
},
112112
"test.o": {
113113
".text": 0,
114114
".data": 0,
@@ -132,7 +132,7 @@ def memap_parser():
132132
".flash_config":0,
133133
"unknown":0,
134134
"OUTPUT":0,
135-
},
135+
},
136136
}
137137
return memap_parser
138138

@@ -142,8 +142,10 @@ def generate_test_helper(memap_parser, format, depth, file_output=None):
142142
Helper that tests that the member variables "modules" is
143143
unchanged after calling "generate_output"
144144
145-
:param output_type: type string that is passed to "generate_output"
146-
:param file_output: path to output file that is passed to "generate_output"
145+
:param memap_parser: the parser object
146+
:param depth: how much detail to put in the report
147+
:param format: the file type to output
148+
:param file_output: the file to output to
147149
"""
148150

149151
old_modules = deepcopy(memap_parser.modules)
@@ -158,6 +160,9 @@ def generate_test_helper(memap_parser, format, depth, file_output=None):
158160
def test_report_computed(memap_parser, depth):
159161
"""
160162
Test that a report and summary are computed
163+
164+
:param memap_parser: Mocked parser
165+
:param depth: the detail of the output
161166
"""
162167

163168
memap_parser.generate_output('table', depth)
@@ -171,6 +176,8 @@ def test_report_computed(memap_parser, depth):
171176
def test_generate_output_table(memap_parser, depth):
172177
"""
173178
Test that an output of type "table" can be generated correctly
179+
:param memap_parser: Mocked parser
180+
:param depth: the detail of the output
174181
"""
175182
generate_test_helper(memap_parser, 'table', depth)
176183

@@ -179,8 +186,11 @@ def test_generate_output_table(memap_parser, depth):
179186
def test_generate_output_json(memap_parser, tmpdir, depth):
180187
"""
181188
Test that an output of type "json" can be generated correctly
189+
:param memap_parser: Mocked parser
190+
:param tmpdir: a unique location to place an output file
191+
:param depth: the detail of the output
182192
"""
183-
file_name = str(tmpdir.join('json_test_output.json').realpath())
193+
file_name = str(tmpdir.join('output.json').realpath())
184194
generate_test_helper(memap_parser, 'json', depth, file_name)
185195
assert isfile(file_name), "Failed to create json file"
186196
json.load(open(file_name))
@@ -191,8 +201,10 @@ def test_generate_output_csv_ci(memap_parser, tmpdir, depth):
191201
"""
192202
Test ensures that an output of type "csv-ci" can be generated correctly
193203
194-
:return:
204+
:param memap_parser: Mocked parser
205+
:param tmpdir: a unique location to place an output file
206+
:param depth: the detail of the output
195207
"""
196-
file_name = str(tmpdir.join('.csv_ci_test_output.csv').realpath())
208+
file_name = str(tmpdir.join('output.csv').realpath())
197209
generate_test_helper(memap_parser, 'csv-ci', depth, file_name)
198210
assert isfile(file_name), "Failed to create csv-ci file"

tools/test/targets/target_test.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ def test_device_name():
3939

4040
@contextmanager
4141
def temp_target_file(extra_target, json_filename='custom_targets.json'):
42-
"""Create an extra targets temp file in a context manager"""
42+
"""Create an extra targets temp file in a context manager
43+
44+
:param extra_target: the contents of the extra targets temp file
45+
"""
4346
tempdir = tempfile.mkdtemp()
4447
try:
4548
targetfile = os.path.join(tempdir, json_filename)
@@ -67,7 +70,7 @@ def test_add_extra_targets():
6770

6871
assert 'Test_Target' in TARGET_MAP
6972
assert TARGET_MAP['Test_Target'].core is None, \
70-
"attributes should be inherited from Target"
73+
"attributes should be inherited from Target"
7174

7275
def test_modify_existing_target():
7376
"""Set default targets file, then override base Target definition"""

tools/test/test_api/test_api_test.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ def test_find_tests_app_config(base_dir, target, toolchain_name, app_config):
4242
"""
4343
Test find_tests for correct use of app_config
4444
45-
:param mock_prepare_toolchain: mock of function prepare_toolchain
46-
:param mock_scan_resources: mock of function scan_resources
47-
:return:
45+
:param base_dir: dummy value for the test base directory
46+
:param target: the target to "test" for
47+
:param toolchain_name: the toolchain to use for "testing"
48+
:param app_config: Application configuration parameter to find tests
4849
"""
4950
set_targets_json_location()
5051
with patch('tools.test_api.scan_resources') as mock_scan_resources,\
@@ -68,9 +69,10 @@ def test_find_tests_app_config(build_path, target, toolchain_name, app_config):
6869
"""
6970
Test find_tests for correct use of app_config
7071
71-
:param mock_prepare_toolchain: mock of function prepare_toolchain
72-
:param mock_scan_resources: mock of function scan_resources
73-
:return:
72+
:param base_dir: dummy value for the test base directory
73+
:param target: the target to "test" for
74+
:param toolchain_name: the toolchain to use for "testing"
75+
:param app_config: Application configuration parameter to find tests
7476
"""
7577
tests = {'test1': 'test1_path','test2': 'test2_path'}
7678
src_paths = ['.']

0 commit comments

Comments
 (0)