Skip to content

Commit dfb29c5

Browse files
minor corrections (change requests)
1 parent adf450f commit dfb29c5

File tree

9 files changed

+25
-20
lines changed

9 files changed

+25
-20
lines changed

swig/openscap_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def introspect_all(self):
242242
""" Listing all builtin functions accessible through SWIG """
243243
return OSCAP.__dict__
244244

245-
def introspect(self):
245+
def introspect_functions(self):
246246
''' Returns all builtin function accessible through SWIG
247247
which is corresponding to the current object
248248
'''
@@ -292,7 +292,7 @@ def __getattr__(self, name):
292292
except:
293293
return self.__func_wrapper(obj)
294294

295-
""" Looking if it's can be a constructor """
295+
""" Looking if it can be a constructor """
296296
obj = OSCAP.__dict__.get(self.object + "_" + name + "_new")
297297
if obj is not None:
298298
# this will call the __call__ definition of OSCAP_Object

tests/bindings/python/benchmark_import_results.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,22 @@
2323
print(test_result.get_id())
2424

2525
for rs in test_result.get_rule_results():
26-
print(rs.get_idref(), result2str(rs.get_result()))
26+
idref, result = rs.get_idref(), rs.get_result()
27+
print(idref, result2str(result))
2728

28-
if (rs.get_idref() == "R-SHOULD_PASS" and
29-
rs.get_result() != oscap.xccdf.XCCDF_RESULT_PASS):
29+
if (idref == "R-SHOULD_PASS" and
30+
result != oscap.xccdf.XCCDF_RESULT_PASS):
3031

3132
raise Exception("Rule result for {0} should be PASS but is currently {1}."
32-
.format(rs.get_idref(),
33-
result2str(rs.get_result())))
33+
.format(idref,
34+
result2str(result)))
3435

35-
elif (rs.get_idref() == "R-SHOULD_FAIL" and
36-
rs.get_result() != oscap.xccdf.XCCDF_RESULT_FAIL):
36+
elif (idref == "R-SHOULD_FAIL" and
37+
result != oscap.xccdf.XCCDF_RESULT_FAIL):
3738

3839
raise Exception("Rule result for {0} should be FAIL but is currently {1}."
39-
.format(rs.get_idref(),
40-
result2str(rs.get_result())))
40+
.format(idref,
41+
result2str(result)))
4142

4243

4344
# Now ensure that benchmark_import return None if the file doesn't exists

tests/bindings/python/import_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def result2str(result):
5353

5454
'''
5555
Return the absolute path of a relative path (located in this folder)
56-
Required because the tests are runned from the build directory,
56+
Required because the tests are run from the build directory,
5757
so you need to use this functions for all relative paths.
5858
'''
5959

tests/bindings/python/introspection_features.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Dominique Blaze <[email protected]>
55
#
66
# Description:
7-
# Test introspection features of python the api
7+
# Test introspection features of Python API
88
# - Test the presence or the absence of expected builtins functions
99
# - Indentify a constant name by its value and prefix (prefix XCCDF_RESULT
1010
# with value 1 (usually) should identify XCCDF_RESULT_PASS
@@ -16,15 +16,15 @@
1616
from import_handler import oscap
1717
from pprint import pprint
1818

19-
oval_funcs = oscap.oval.introspect()
19+
oval_funcs = oscap.oval.introspect_functions()
2020

2121
if oval_funcs.get('oval_variable_get_values') is None:
2222
raise Exception("method 'oval_variable_get_values' not found in builtins"
23-
"functions of oval object (should be in oscap.oval.introspect())")
23+
"functions of oval object (should be in oscap.oval.introspect_functions())")
2424

2525
if oval_funcs.get('xccdf_check_get_id') is not None:
2626
raise Exception("method 'xccdf_check_get_id' should not be found in "
27-
"oscap.oval.introspect(), because the prefix isn't 'oval')")
27+
"oscap.oval.introspect_functions(), because the prefix isn't 'oval')")
2828

2929
if oscap.oval.introspect_all().get('xccdf_check_get_id') is None:
3030
raise Exception("method 'xccdf_check_get_id' should be present in "

tests/bindings/python/oval_eval.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
# if you return something in callback else than 0, the current session stops
4747
def oval_sample_callback(ovdef, usr):
4848
# .eval or .get_result return the same thing
49-
print(ovdef.get_id()+" => "+result2str(ovdef.get_result()))
49+
print(ovdef.get_id() + " => " + result2str(ovdef.get_result()))
5050

5151
# retrieve the tests tree and replace test_results by [subtype => result]
5252
tests_tree = browse_criteria(ovdef.get_criteria(), 1)

tests/bindings/python/oval_helpers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
# to provide convenience utilities.
1010
#
1111

12+
from import_handler import oscap
13+
1214

1315
def browse_criteria(crit_node, mode=0):
1416
'''

tests/bindings/python/samples/oval_sample.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434
</definitions>
3535

3636
<tests>
37-
<ind:textfilecontent54_test id="oval:foo_pass:tst:1" version="1" comment="File /tmp/foo_python.txt must contains at least one 'Hello'" check="at least one">
37+
<ind:textfilecontent54_test id="oval:foo_pass:tst:1" version="1" comment="File /tmp/foo_python.txt must contain at least one 'Hello'" check="at least one">
3838
<ind:object object_ref="oval:foo:obj:1"/>
3939
<ind:state state_ref="oval:foo_pass:ste:1"/>
4040
</ind:textfilecontent54_test>
4141

42-
<ind:textfilecontent54_test id="oval:foo_fail:tst:1" version="1" comment="File /tmp/foo_python.txt must not contains 'Hello'" check="all">
42+
<ind:textfilecontent54_test id="oval:foo_fail:tst:1" version="1" comment="File /tmp/foo_python.txt must not contain 'Hello'" check="all">
4343
<ind:object object_ref="oval:foo:obj:1"/>
4444
<ind:state state_ref="oval:foo_fail:ste:1"/>
4545
</ind:textfilecontent54_test>

tests/bindings/python/xccdf_policy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
benchmark = pm.get_benchmark()
6262
expected_benchmark_id = "xccdf_com.example.www_benchmark_test"
6363
if benchmark.get_id() != expected_benchmark_id:
64-
raise Exception("Benchmark id should be {0} but is currently {0}"
64+
raise Exception("Benchmark id should be {0} but is currently {1}"
6565
.format(expected_benchmark_id, benchmark.get_id()))
6666

6767
print("Browsing profiles ...")

tests/bindings/test_python.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ if [ -z ${CUSTOM_OSCAP+x} ] ; then
3838
test_run "python_xccdf_policy" run_pyfile xccdf_policy.py
3939
fi
4040

41+
rm /tmp/foo_python.txt
42+
4143
test_exit

0 commit comments

Comments
 (0)