def test_build_ulimits_with_integers(self): self.assertEqual( build_ulimits({'nofile': { 'soft': 10000, 'hard': 20000 }}), [{ 'name': 'nofile', 'soft': 10000, 'hard': 20000 }]) self.assertEqual( self.sort_dicts_by_name( build_ulimits({ 'nofile': { 'soft': 10000, 'hard': 20000 }, 'nproc': { 'soft': 65535, 'hard': 65535 } })), self.sort_dicts_by_name([{ 'name': 'nofile', 'soft': 10000, 'hard': 20000 }, { 'name': 'nproc', 'soft': 65535, 'hard': 65535 }]))
def test_build_ulimits_with_dicts(self): self.assertEqual(build_ulimits( {'nofile': 20000}), [{'name': 'nofile', 'soft': 20000, 'hard': 20000}]) self.assertEqual(self.sort_dicts_by_name(build_ulimits( {'nofile': 20000, 'nproc': 65535})), self.sort_dicts_by_name([{'name': 'nofile', 'soft': 20000, 'hard': 20000}, {'name': 'nproc', 'soft': 65535, 'hard': 65535}]))
def test_build_ulimits_with_ints(self): ulimits = build_ulimits({'nofile': 20000, 'nproc': 65535}) expected = [ {'name': 'nofile', 'soft': 20000, 'hard': 20000}, {'name': 'nproc', 'soft': 65535, 'hard': 65535} ] assert sort_by_name(ulimits) == sort_by_name(expected)
def test_build_ulimits_with_invalid_options(self): self.assertRaises( ConfigError, lambda: build_ulimits({'nofile': { 'soft': 10000, 'hard': 10 }}))
def test_build_ulimits_with_invalid_options(self): self.assertRaises(ConfigError, lambda: build_ulimits({'nofile': {'soft': 10000, 'hard': 10}}))