test_version.py 1.3 KB

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