test_version.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #! /usr/bin/env python
  2. from __future__ import absolute_import
  3. from __future__ import print_function
  4. import sys
  5. import os
  6. import unittest
  7. import greenlet
  8. class VersionTests(unittest.TestCase):
  9. def test_version(self):
  10. def find_dominating_file(name):
  11. if os.path.exists(name):
  12. return name
  13. tried = []
  14. here = os.path.abspath(os.path.dirname(__file__))
  15. for i in range(10):
  16. up = ['..'] * i
  17. path = [here] + up + [name]
  18. fname = os.path.join(*path)
  19. fname = os.path.abspath(fname)
  20. tried.append(fname)
  21. if os.path.exists(fname):
  22. return fname
  23. raise AssertionError("Could not find file " + name + "; checked " + str(tried))
  24. try:
  25. setup_py = find_dominating_file('setup.py')
  26. except AssertionError as e:
  27. raise unittest.SkipTest("Unable to find setup.py; must be out of tree. " + str(e))
  28. invoke_setup = "%s %s --version" % (sys.executable, setup_py)
  29. with os.popen(invoke_setup) as f:
  30. sversion = f.read().strip()
  31. self.assertEqual(sversion, greenlet.__version__)