Skip to content

Commit 4853e05

Browse files
committed
Check version_check.
Version check should also exclude 3.0-3.5 or there abouts, so get code coverage first.
1 parent f7fa2be commit 4853e05

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/test_misc.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import unittest
44
import roundup.anypy.cmp_
5+
import sys
6+
from roundup.anypy.strings import StringIO # define StringIO
57
from roundup.cgi.accept_language import parse
68

79
class AcceptLanguageTest(unittest.TestCase):
@@ -30,3 +32,34 @@ def testParse(self):
3032
class CmpTest(unittest.TestCase):
3133
def testCmp(self):
3234
roundup.anypy.cmp_._test()
35+
36+
class VersionCheck(unittest.TestCase):
37+
def test_Version_Check(self):
38+
39+
# test for valid versions
40+
from roundup.version_check import VERSION_NEEDED
41+
self.assertEqual((2, 7), VERSION_NEEDED)
42+
del(sys.modules['roundup.version_check'])
43+
44+
45+
# fake an invalid version
46+
real_ver = sys.version_info
47+
sys.version_info = (2, 1)
48+
49+
# exit is called on failure, but that breaks testing so
50+
# just return and discard the exit code.
51+
real_exit = sys.exit
52+
sys.exit = lambda code: code
53+
54+
# error case uses print(), capture and check
55+
capturedOutput = StringIO()
56+
sys.stdout = capturedOutput
57+
from roundup.version_check import VERSION_NEEDED
58+
sys.stdout = sys.__stdout__
59+
self.assertIn("Roundup requires Python 2.7", capturedOutput.getvalue())
60+
61+
# reset to valid values for future tests
62+
sys.exit = real_exit
63+
sys.version_info = real_ver
64+
65+

0 commit comments

Comments
 (0)