test_dist3.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Copyright (c) Twisted Matrix Laboratories.
  2. # See LICENSE for details.
  3. """
  4. Tests for L{twisted.python.dist3}.
  5. """
  6. from __future__ import absolute_import, division
  7. import os
  8. import twisted
  9. from twisted.trial.unittest import TestCase
  10. from twisted.python.compat import _PY3
  11. from twisted.python._setup import notPortedModules
  12. class ModulesToInstallTests(TestCase):
  13. """
  14. Tests for L{notPortedModules}.
  15. """
  16. def test_exist(self):
  17. """
  18. All modules listed in L{notPortedModules} exist on Py2.
  19. """
  20. root = os.path.dirname(os.path.dirname(twisted.__file__))
  21. for module in notPortedModules:
  22. segments = module.split(".")
  23. segments[-1] += ".py"
  24. path = os.path.join(root, *segments)
  25. alternateSegments = module.split(".") + ["__init__.py"]
  26. packagePath = os.path.join(root, *alternateSegments)
  27. self.assertTrue(os.path.exists(path) or
  28. os.path.exists(packagePath),
  29. "Module {0} does not exist".format(module))
  30. def test_notexist(self):
  31. """
  32. All modules listed in L{notPortedModules} do not exist on Py3.
  33. """
  34. root = os.path.dirname(os.path.dirname(twisted.__file__))
  35. for module in notPortedModules:
  36. segments = module.split(".")
  37. segments[-1] += ".py"
  38. path = os.path.join(root, *segments)
  39. alternateSegments = module.split(".") + ["__init__.py"]
  40. packagePath = os.path.join(root, *alternateSegments)
  41. self.assertFalse(os.path.exists(path) or
  42. os.path.exists(packagePath),
  43. "Module {0} exists".format(module))
  44. if _PY3:
  45. test_exist.skip = "Only on Python 2"
  46. else:
  47. test_notexist.skip = "Only on Python 3"