test_version.py 1.0 KB

12345678910111213141516171819202122232425262728
  1. # This Source Code Form is subject to the terms of the Mozilla Public
  2. # License, v. 2.0. If a copy of the MPL was not distributed with this
  3. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. import os
  5. import unittest
  6. import shutil
  7. from cuddlefish._version import get_versions
  8. class Version(unittest.TestCase):
  9. def get_basedir(self):
  10. return os.path.join(".test_tmp", self.id())
  11. def make_basedir(self):
  12. basedir = self.get_basedir()
  13. if os.path.isdir(basedir):
  14. here = os.path.abspath(os.getcwd())
  15. assert os.path.abspath(basedir).startswith(here) # safety
  16. shutil.rmtree(basedir)
  17. os.makedirs(basedir)
  18. return basedir
  19. def test_current_version(self):
  20. # the SDK should be able to determine its own version. We don't care
  21. # what it is, merely that it can be computed.
  22. version = get_versions()["version"]
  23. self.failUnless(isinstance(version, str), (version, type(version)))
  24. self.failUnless(len(version) > 0, version)