test_appdirs.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # Copyright (c) Twisted Matrix Laboratories.
  2. # See LICENSE for details.
  3. """
  4. Tests for the data directory support.
  5. """
  6. from __future__ import division, absolute_import
  7. try:
  8. from twisted.python import _appdirs
  9. except ImportError:
  10. _appdirs = None
  11. from twisted.trial import unittest
  12. class AppdirsTests(unittest.TestCase):
  13. """
  14. Tests for L{_appdirs}.
  15. """
  16. if not _appdirs:
  17. skip = "appdirs package not installed"
  18. def test_moduleName(self):
  19. """
  20. Calling L{appdirs.getDataDirectory} will return a user data directory
  21. in the system convention, with the module of the caller as the
  22. subdirectory.
  23. """
  24. res = _appdirs.getDataDirectory()
  25. self.assertTrue(res.endswith("twisted.python.test.test_appdirs"))
  26. def test_manual(self):
  27. """
  28. Calling L{appdirs.getDataDirectory} with a C{moduleName} argument will
  29. make a data directory with that name instead.
  30. """
  31. res = _appdirs.getDataDirectory("foo.bar.baz")
  32. self.assertTrue(res.endswith("foo.bar.baz"))