Skip to content

Commit 09e3677

Browse files
committed
Fixed Test.py and changed its location
Enjoy testing, no more problemo. I didn't knew that i was having trouble with function and instances and using lambda could have been easy fix
1 parent cc128f5 commit 09e3677

4 files changed

Lines changed: 20 additions & 12 deletions

File tree

.vscode/settings.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
{
22
"docwriter.progress.trackMethods": false,
33
"docwriter.progress.trackFunctions": true,
4-
"docwriter.progress.trackClasses": true
4+
"docwriter.progress.trackClasses": true,
5+
"python.testing.unittestArgs": [
6+
"-v",
7+
"-s",
8+
"./tests",
9+
"-p",
10+
"*test*.py"
11+
],
12+
"python.testing.pytestEnabled": false,
13+
"python.testing.unittestEnabled": true
514
}

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ rpds-py==0.20.0
3333
six==1.16.0
3434
twine==5.1.1
3535
urllib3==2.2.2
36-
zipp==3.20.1
36+
zipp==3.20.1

src/core.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,8 @@ def load_average(self) -> dict:
108108
}
109109
def time_of_file(self,file_path: str) -> float:
110110
start = time.perf_counter()
111-
with open(file_path) as file:
112-
exec(file.read())
111+
113112
end = time.perf_counter()
114113
total = end - start
115114
print(total)
116115

117-
print(System_Usage("GB").network_info())

src/tests/test.py renamed to tests/test.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class Test_Usage(unittest.TestCase):
66
def __init__(self, methodName: str = "runTest") -> None:
77
super().__init__(methodName)
8-
self.sys_usage = System_Usage()
8+
self.sys_usage = lambda unit: System_Usage(unit)
99
@patch('psutil.virtual_memory')
1010
def test_memory_info(self,mock_memory):
1111
mock_memory.return_value = MagicMock(
@@ -17,12 +17,13 @@ def test_memory_info(self,mock_memory):
1717
)
1818

1919
expected_result = {
20-
"total": 8,
21-
"available": 4,
22-
"free": 2,
23-
"percent": 50.0,
24-
"used": 4
20+
'total': 8.0,
21+
'available': 4.0,
22+
'free': 2.0,
23+
'percent': '50.0%',
24+
'used': 4.0
2525
}
2626

27-
result = self.sys_usage.memory_info(unit='GB')
27+
result = self.sys_usage(unit='GB').memory_info()
28+
result = dict((key,value) for key,value in result.items() if key in expected_result)
2829
self.assertEqual(result, expected_result)

0 commit comments

Comments
 (0)