Skip to content

Commit

Permalink
Fixed Test.py and changed its location
Browse files Browse the repository at this point in the history
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
  • Loading branch information
CoderLogy committed Feb 7, 2025
1 parent cc128f5 commit 09e3677
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
11 changes: 10 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"docwriter.progress.trackMethods": false,
"docwriter.progress.trackFunctions": true,
"docwriter.progress.trackClasses": true
"docwriter.progress.trackClasses": true,
"python.testing.unittestArgs": [
"-v",
"-s",
"./tests",
"-p",
"*test*.py"
],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true
}
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ rpds-py==0.20.0
six==1.16.0
twine==5.1.1
urllib3==2.2.2
zipp==3.20.1
zipp==3.20.1
4 changes: 1 addition & 3 deletions src/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,8 @@ def load_average(self) -> dict:
}
def time_of_file(self,file_path: str) -> float:
start = time.perf_counter()
with open(file_path) as file:
exec(file.read())

end = time.perf_counter()
total = end - start
print(total)

print(System_Usage("GB").network_info())
15 changes: 8 additions & 7 deletions src/tests/test.py → tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class Test_Usage(unittest.TestCase):
def __init__(self, methodName: str = "runTest") -> None:
super().__init__(methodName)
self.sys_usage = System_Usage()
self.sys_usage = lambda unit: System_Usage(unit)
@patch('psutil.virtual_memory')
def test_memory_info(self,mock_memory):
mock_memory.return_value = MagicMock(
Expand All @@ -17,12 +17,13 @@ def test_memory_info(self,mock_memory):
)

expected_result = {
"total": 8,
"available": 4,
"free": 2,
"percent": 50.0,
"used": 4
'total': 8.0,
'available': 4.0,
'free': 2.0,
'percent': '50.0%',
'used': 4.0
}

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

0 comments on commit 09e3677

Please sign in to comment.