Skip to content

Commit bc275b3

Browse files
committed
fixed tests
1 parent f6c858c commit bc275b3

17 files changed

Lines changed: 94 additions & 80 deletions

tests/test_apicalls.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# SPDX-FileCopyrightText: 2025-present Maikel Mardjan(https://nocomplexity.com/) and all contributors!
2+
#
3+
# SPDX-License-Identifier: GPL-3.0-or-later
4+
15
import pytest
26
from pathlib import Path
37

@@ -51,7 +55,7 @@ def test_get_overview_validfile():
5155
# This is the expected dictionary - note for testing output!
5256
expected_data = {
5357
"FileName": "obfuscating.py",
54-
"Number_Of_Lines": 68,
58+
"Number_Of_Lines": 54,
5559
"AST_Nodes": 32,
5660
"Std-Modules": 2,
5761
"External-Modules": 0,

tests/test_basicpatterns.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_basic_patterns():
1717
actual_data = find_constructs(source, constructs)
1818

1919
# This is the expected dictionary
20-
expected_data = {"os.access": [9, 15], "eval": [12]}
20+
expected_data = {"os.access": [8, 14], "eval": [11]}
2121

2222
# Assert that the actual data matches the expected data
2323
assert actual_data == expected_data
@@ -35,7 +35,7 @@ def test_basic_patterns2():
3535
actual_data = find_constructs(source, constructs)
3636

3737
# This is the expected dictionary
38-
expected_data = {"os.access": [9, 13], "eval": [11], "os": [9, 13]}
38+
expected_data = {"os.access": [8, 12], "eval": [10], "os": [8, 12]}
3939

4040
# Assert that the actual data matches the expected data
4141
assert actual_data == expected_data
@@ -52,7 +52,7 @@ def test_assert_keyword():
5252
actual_data = find_constructs(source, constructs)
5353

5454
# This is the expected dictionary
55-
expected_data = {"assert": [4, 31]}
55+
expected_data = {"assert": [5, 31]}
5656

5757
# Assert that the actual data matches the expected data
5858
assert actual_data == expected_data

tests/test_chmod.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_chmod_constructs():
2020
actual_data = result["result"]
2121

2222
# This is the expected dictionary
23-
expected_data = {"os.access": [6], "os.chmod": [9, 26, 28]}
23+
expected_data = {"os.access": [5], "os.chmod": [8, 23, 25]}
2424

2525
# Assert that the actual data matches the expected data
2626
assert actual_data == expected_data

tests/test_constructspart2.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_zipfile_extraction():
3939

4040
# This is the expected dictionary
4141
expected_data = {
42-
"zipfile.ZipFile": [9, 14, 18, 25],
42+
"zipfile.ZipFile": [8, 13, 17, 23],
4343
}
4444

4545
# Assert that the actual data matches the expected data
@@ -60,11 +60,11 @@ def test_shutil_constructs():
6060
# This is the expected dictionary
6161
expected_data = {
6262
"shutil.unpack_archive": [3],
63-
"shutil.copy2": [5, 12],
63+
"shutil.copy2": [5, 7],
6464
"shutil.copytree": [7],
65-
"shutil.chown": [17],
66-
"shutil.rmtree": [25],
67-
"shutil.copy": [29],
65+
"shutil.chown": [9],
66+
"shutil.rmtree": [15],
67+
"shutil.copy": [18],
6868
}
6969

7070
# Assert that the actual data matches the expected data
@@ -85,7 +85,7 @@ def test_input_statement():
8585
actual_data = result["result"]
8686

8787
# This is the expected dictionary
88-
expected_data = {"input": [7]}
88+
expected_data = {"input": [6]}
8989

9090
# Assert that the actual data matches the expected data
9191
assert actual_data == expected_data
@@ -103,7 +103,7 @@ def test_marshal_usage():
103103
actual_data = result["result"]
104104

105105
# This is the expected dictionary
106-
expected_data = {"marshal.loads": [31], "marshal.load": [37]}
106+
expected_data = {"marshal.loads": [30], "marshal.load": [36]}
107107

108108
# Assert that the actual data matches the expected data
109109
assert actual_data == expected_data
@@ -123,7 +123,7 @@ def test_tar_methods_use():
123123
actual_data = result["result"]
124124

125125
# This is the expected dictionary
126-
expected_data = {"tarfile.TarFile": [7, 12, 21, 27, 29]}
126+
expected_data = {"tarfile.TarFile": [6, 10, 17, 22, 24]}
127127

128128
# Assert that the actual data matches the expected data
129129
assert actual_data == expected_data

tests/test_correctexceptionuse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_correct_exception_use():
1717
actual_data = find_constructs(source, constructs)
1818

1919
# This is the expected dictionary
20-
expected_data = {"pass": [20], "continue": [12]}
20+
expected_data = {"pass": [19], "continue": [11]}
2121

2222
# Assert that the actual data matches the expected data
2323
assert actual_data == expected_data

tests/test_directorycreation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_os_makedirs():
1717
actual_data = find_constructs(source, constructs)
1818

1919
# This is the expected dictionary
20-
expected_data = {"os.makedirs": [10, 77]}
20+
expected_data = {"os.makedirs": [10, 79]}
2121

2222
# Assert that the actual data matches the expected data
2323
assert actual_data == expected_data
@@ -35,7 +35,7 @@ def test_os_mkdir():
3535
actual_data = find_constructs(source, constructs)
3636

3737
# This is the expected dictionary
38-
expected_data = {"os.mkdir": [22]}
38+
expected_data = {"os.mkdir": [23]}
3939

4040
# Assert that the actual data matches the expected data
4141
assert actual_data == expected_data
@@ -53,7 +53,7 @@ def test_os_mkfifo():
5353
actual_data = find_constructs(source, constructs)
5454

5555
# This is the expected dictionary
56-
expected_data = {"os.mkfifo": [44]}
56+
expected_data = {"os.mkfifo": [45]}
5757

5858
# Assert that the actual data matches the expected data
5959
assert actual_data == expected_data
@@ -71,7 +71,7 @@ def test_os_mknod():
7171
actual_data = find_constructs(source, constructs)
7272

7373
# This is the expected dictionary
74-
expected_data = {"os.mknod": [61]}
74+
expected_data = {"os.mknod": [62]}
7575

7676
# Assert that the actual data matches the expected data
7777
assert actual_data == expected_data

tests/test_directorycreation2.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_os_mkdir():
3535
actual_data = find_constructs(source, constructs)
3636

3737
# This is the expected dictionary
38-
expected_data = {"os.mkdir": [25]}
38+
expected_data = {"os.mkdir": [26]}
3939

4040
# Assert that the actual data matches the expected data
4141
assert actual_data == expected_data
@@ -53,7 +53,7 @@ def test_os_mkfifo():
5353
actual_data = find_constructs(source, constructs)
5454

5555
# This is the expected dictionary
56-
expected_data = {"os.mkfifo": [47]}
56+
expected_data = {"os.mkfifo": [48]}
5757

5858
# Assert that the actual data matches the expected data
5959
assert actual_data == expected_data
@@ -71,7 +71,7 @@ def test_os_mknod():
7171
actual_data = find_constructs(source, constructs)
7272

7373
# This is the expected dictionary
74-
expected_data = {"os.mknod": [64]}
74+
expected_data = {"os.mknod": [65]}
7575

7676
# Assert that the actual data matches the expected data
7777
assert actual_data == expected_data
@@ -89,7 +89,7 @@ def test_os_makedirs():
8989
actual_data = find_constructs(source, constructs)
9090

9191
# This is the expected dictionary
92-
expected_data = {"os.makedirs": [13, 80]}
92+
expected_data = {"os.makedirs": [13, 82]}
9393

9494
# Assert that the actual data matches the expected data
9595
assert actual_data == expected_data
@@ -107,7 +107,7 @@ def test_os_makedev():
107107
actual_data = find_constructs(source, constructs)
108108

109109
# This is the expected dictionary
110-
expected_data = {"os.makedev": [92]}
110+
expected_data = {"os.makedev": [94]}
111111

112112
# Assert that the actual data matches the expected data
113113
assert actual_data == expected_data
@@ -124,9 +124,9 @@ def test_sys_calls():
124124

125125
# This is the expected dictionary
126126
expected_data = {
127-
"sys.call_tracing": [15],
128-
"sys.setprofile": [34, 36],
129-
"sys.settrace": [41, 43],
127+
"sys.call_tracing": [12],
128+
"sys.setprofile": [29, 31],
129+
"sys.settrace": [35, 37],
130130
}
131131

132132
# Assert that the actual data matches the expected data

tests/test_edgecases.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def test_eval():
3838
# This is the expected dictionary
3939
expected_data = {
4040
"exec": [5],
41-
"eval": [8, 11, 12, 13, 22, 25, 28, 30, 32],
42-
"__import__": [32],
41+
"eval": [8, 11, 12, 13, 21, 23, 26, 28, 30],
42+
"__import__": [30],
4343
}
4444

4545
# Assert that the actual data matches the expected data
@@ -78,7 +78,7 @@ def test_eval2():
7878
actual_data = result["result"]
7979

8080
# This is the expected dictionary
81-
expected_data = {"eval": [10]}
81+
expected_data = {"eval": [8]}
8282

8383
# Assert that the actual data matches the expected data
8484
assert actual_data == expected_data

tests/test_hashstrenght.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_hash_strenght():
1717
actual_data = find_constructs(source, constructs)
1818

1919
# This is the expected dictionary
20-
expected_data = {"hashlib.md5": [20], "hashlib.sha1": [21, 49]}
20+
expected_data = {"hashlib.md5": [19], "hashlib.sha1": [20, 48]}
2121

2222
# Assert that the actual data matches the expected data
2323
assert actual_data == expected_data

tests/test_obfuscatingbuiltins.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ def test_obfucatedbuiltins_usage():
2121

2222
# This is the expected dictionary
2323
expected_data = {
24-
"exec": [6, 17, 22, 37, 43, 44],
25-
"eval": [8, 12, 47],
26-
"input": [28, 33, 64],
27-
"compile": [36],
28-
"importlib.import_module": [65],
29-
"__import__": [43, 44, 47, 53, 58],
24+
"exec": [5, 16, 21, 32, 36, 37],
25+
"eval": [7, 11, 40],
26+
"input": [25, 28, 52],
27+
"compile": [31],
28+
"importlib.import_module": [53],
29+
"__import__": [36, 37, 40, 44, 47],
3030
}
3131

3232
# Assert that the actual data matches the expected data

0 commit comments

Comments
 (0)