def check_memvalue(job_desc): '''Check if the correct memory limit is applied''' specified_memory_value = job_desc.get('memory-limit', default_memory_limit) if isinstance(specified_memory_value, int): expected_memory_value = specified_memory_value else: expected_memory_value = \ memory_size_human_to_bytes(specified_memory_value) with patch('resource.setrlimit') as resource_setrlimit: set_memory_limit(job_desc) eq_(resource_setrlimit.mock_calls, [call(resource.RLIMIT_AS, (expected_memory_value, -1))])
def check_memory_invalid(invalid_job_desc): with patch('resource.setrlimit'): with assert_raises(Exception): set_memory_limit(invalid_job_desc)