11import os
22import unittest
33
4- from hamcrest import *
4+ from hamcrest import assert_that , is_ , less_than
55from psutil import AccessDenied , process_iter , virtual_memory
66
77from utilities .utilities import (
2222
2323
2424class TestMemoryUsage (unittest .TestCase ):
25- def setUp (self ):
25+ def setUp (self ) -> None :
2626 g .set_instrument (None )
2727
2828 setup_simulated_wiring_tables ()
2929
30- # all tests that interact with anything but genie should try to load a config to ensure that the configurations
30+ # all tests that interact with anything but genie should try to load
31+ # a config to ensure that the configurations
3132 # in the tests are not broken, e.g. by a schema update
3233 load_config_if_not_already_loaded (TYPICAL_CONFIG_NAME )
3334
34- def get_current_memory_usage (self ):
35+ def get_current_memory_usage (self ) -> float :
3536 """
3637 Obtains the current system memory usage and returns it in gibibytes
3738
@@ -60,7 +61,7 @@ def get_current_memory_usage(self):
6061
6162 def test_GIVEN_typical_config_with_IOCs_blocks_and_LVDCOM_IOC_WHEN_dae_is_doing_a_run_THEN_memory_usage_stays_under_9point5gb (
6263 self ,
63- ):
64+ ) -> None :
6465 system_threshold = 9.5
6566
6667 g .begin ()
@@ -71,7 +72,7 @@ def test_GIVEN_typical_config_with_IOCs_blocks_and_LVDCOM_IOC_WHEN_dae_is_doing_
7172
7273 def test_GIVEN_typical_config_with_IOCs_blocks_and_LVDCOM_IOC_WHEN_dae_is_not_doing_a_run_THEN_memory_usage_stays_under_7point5gb (
7374 self ,
74- ):
75+ ) -> None :
7576 system_threshold = 8.5
7677
7778 memory_used = self .get_current_memory_usage ()
@@ -80,7 +81,7 @@ def test_GIVEN_typical_config_with_IOCs_blocks_and_LVDCOM_IOC_WHEN_dae_is_not_do
8081
8182 def get_matching_process_cmdline_substring_from_process_or_none (
8283 self , process , process_cmdline_substrings
83- ):
84+ ) -> str :
8485 """
8586 Get the first substring from process_cmdline_substrings that is contained in the cmdline call for the process
8687 or None if no substrings match.
@@ -90,7 +91,7 @@ def get_matching_process_cmdline_substring_from_process_or_none(
9091 if process_cmdline_substring in cmdline :
9192 return process_cmdline_substring
9293
93- def get_commit_sizes_in_kb (self , process_cmdline_substrings ):
94+ def get_commit_sizes_in_kb (self , process_cmdline_substrings ) -> dict () :
9495 """
9596 Get the commit sizes of the processes that contain the given substrings in their command line call.
9697 """
@@ -111,7 +112,7 @@ def get_commit_sizes_in_kb(self, process_cmdline_substrings):
111112
112113 def assert_commit_sizes_are_less_than_expected_max_commit_size (
113114 self , process_cmdline_substrings_and_expected_max_commit_size , commit_sizes_in_kb
114- ):
115+ ) -> None :
115116 assertion_error_occurred = False
116117 for process_cmdline_substring , commit_size_in_kb in commit_sizes_in_kb .items ():
117118 try :
@@ -130,7 +131,7 @@ def assert_commit_sizes_are_less_than_expected_max_commit_size(
130131 f"Expected commit size to be less than values: { process_cmdline_substrings_and_expected_max_commit_size } . Actually got: { commit_sizes_in_kb } "
131132 )
132133
133- def test_GIVEN_standard_setup_THEN_commit_size_of_python_processes_are_reasonable (self ):
134+ def test_GIVEN_standard_setup_THEN_commit_size_of_python_processes_are_reasonable (self ) -> None :
134135 process_cmdline_substrings_and_expected_max_commit_size = {
135136 "block_server.py" : 900000 ,
136137 "database_server.py" : 900000 ,
0 commit comments