process_test.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
  2. #
  3. # Permission to use, copy, modify, and distribute this software for any
  4. # purpose with or without fee is hereby granted, provided that the above
  5. # copyright notice and this permission notice appear in all copies.
  6. #
  7. # THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
  8. # DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
  9. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
  10. # INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
  11. # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
  12. # FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  13. # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  14. # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. """Tests for isc.util.process."""
  16. import unittest
  17. import isc.util.process
  18. run_tests = True
  19. try:
  20. import setproctitle
  21. except ImportError:
  22. run_tests = False
  23. class TestRename(unittest.TestCase):
  24. """Testcase for isc.process.rename."""
  25. def __get_self_name(self):
  26. return setproctitle.getproctitle()
  27. @unittest.skipIf(not run_tests, "Setproctitle not installed, not testing")
  28. def test_rename(self):
  29. """Test if the renaming function works."""
  30. isc.util.process.rename("rename-test")
  31. self.assertEqual("rename-test", self.__get_self_name())
  32. isc.util.process.rename()
  33. self.assertEqual("process_test.py", self.__get_self_name())
  34. if __name__ == "__main__":
  35. unittest.main()