summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2009-12-13 17:21:58 -0500
committerNed Batchelder <ned@nedbatchelder.com>2009-12-13 17:21:58 -0500
commit5e5c26966ee3d75c17ca33c9d49f8926aefe735b (patch)
tree96e9e9a8550523a6ade00967c823f875d207e330
parent9e134e3f40f34a560860efdb48874f8332629ba4 (diff)
downloadpython-coveragepy-git-5e5c26966ee3d75c17ca33c9d49f8926aefe735b.tar.gz
version_info is a nicer way to check Python versions than hexversion is.
-rw-r--r--coverage/backward.py2
-rw-r--r--coverage/bytecode.py2
-rw-r--r--coverage/files.py2
-rw-r--r--coverage/parser.py2
-rw-r--r--setup.py2
-rw-r--r--test/osinfo.py2
-rw-r--r--test/test_arcs.py4
-rw-r--r--test/test_coverage.py8
-rw-r--r--test/test_oddball.py2
9 files changed, 13 insertions, 13 deletions
diff --git a/coverage/backward.py b/coverage/backward.py
index 624daa2c..425b2f87 100644
--- a/coverage/backward.py
+++ b/coverage/backward.py
@@ -56,7 +56,7 @@ except NameError:
# Exec is a statement in Py2, a function in Py3
-if sys.hexversion > 0x03000000:
+if sys.version_info >= (3, 0):
def exec_function(source, filename, global_map):
"""A wrapper around exec()."""
exec(compile(source, filename, "exec"), global_map)
diff --git a/coverage/bytecode.py b/coverage/bytecode.py
index ac280342..ab522d6c 100644
--- a/coverage/bytecode.py
+++ b/coverage/bytecode.py
@@ -22,7 +22,7 @@ class ByteCodes(object):
self.code = code
self.offset = 0
- if sys.hexversion > 0x03000000:
+ if sys.version_info >= (3, 0):
def __getitem__(self, i):
return self.code[i]
else:
diff --git a/coverage/files.py b/coverage/files.py
index ba228c23..3968b567 100644
--- a/coverage/files.py
+++ b/coverage/files.py
@@ -67,7 +67,7 @@ class FileLocator(object):
data = zi.get_data(parts[1])
except IOError:
continue
- if sys.hexversion > 0x03000000:
+ if sys.version_info >= (3, 0):
data = data.decode('utf8') # TODO: How to do this properly?
return data
return None
diff --git a/coverage/parser.py b/coverage/parser.py
index 43f691f5..cf462181 100644
--- a/coverage/parser.py
+++ b/coverage/parser.py
@@ -310,7 +310,7 @@ class ByteParser(object):
return map(lambda c: ByteParser(code=c), CodeObjects(self.code))
# Getting numbers from the lnotab value changed in Py3.0.
- if sys.hexversion >= 0x03000000:
+ if sys.version_info >= (3, 0):
def _lnotab_increments(self, lnotab):
"""Return a list of ints from the lnotab bytes in 3.x"""
return list(lnotab)
diff --git a/setup.py b/setup.py
index 2d4efaed..4c1a9187 100644
--- a/setup.py
+++ b/setup.py
@@ -33,7 +33,7 @@ import sys
# Distribute is a new fork of setuptools. It's supported on Py3.x, so we use
# it there, but stick with classic setuptools on Py2.x until Distribute becomes
# more accepted.
-if sys.hexversion > 0x03000000:
+if sys.version_info >= (3, 0):
from distribute_setup import use_setuptools
else:
from ez_setup import use_setuptools
diff --git a/test/osinfo.py b/test/osinfo.py
index 8bed2afd..04855fe6 100644
--- a/test/osinfo.py
+++ b/test/osinfo.py
@@ -2,7 +2,7 @@
import sys
-if sys.hexversion >= 0x02050000 and sys.platform == 'win32':
+if sys.version_info >= (2, 5) and sys.platform == 'win32':
# Windows implementation
def process_ram():
"""How much RAM is this process using? (Windows)"""
diff --git a/test/test_arcs.py b/test/test_arcs.py
index 45ab27e8..cbd7645d 100644
--- a/test/test_arcs.py
+++ b/test/test_arcs.py
@@ -212,7 +212,7 @@ class LoopArcTest(CoverageTest):
)
# With "while True", 2.x thinks it's computation, 3.x thinks it's
# constant.
- if sys.hexversion >= 0x03000000:
+ if sys.version_info >= (3, 0):
arcz = ".1 12 23 34 45 36 63 57 27 7."
else:
arcz = ".1 12 23 34 45 36 62 57 27 7."
@@ -387,7 +387,7 @@ class ExceptionArcTest(CoverageTest):
arcz=".1 12 23 34 3D 45 56 67 68 7A 8A A3 AB AD BC CD D.",
arcz_missing="3D AB BC CD", arcz_unpredicted="")
- if sys.hexversion >= 0x02050000:
+ if sys.version_info >= (2, 5):
# Try-except-finally was new in 2.5
def test_except_finally(self):
self.check_coverage("""\
diff --git a/test/test_coverage.py b/test/test_coverage.py
index 9303c063..693b9b33 100644
--- a/test/test_coverage.py
+++ b/test/test_coverage.py
@@ -212,7 +212,7 @@ class SimpleStatementTest(CoverageTest):
""",
[1,2,3,6,9], "")
- if sys.hexversion < 0x03000000: # Print statement is gone in Py3k.
+ if sys.version_info < (3, 0): # Print statement is gone in Py3k.
def testPrint(self):
self.check_coverage("""\
print "hello, world!"
@@ -403,7 +403,7 @@ class SimpleStatementTest(CoverageTest):
""",
[1,2,3,4,5], "")
- if sys.hexversion < 0x03000000:
+ if sys.version_info < (3, 0):
# In Python 2.x, exec is a statement.
def testExec(self):
self.check_coverage("""\
@@ -1393,7 +1393,7 @@ class ExcludeTest(CoverageTest):
[8,9], "", ['#pragma: NO COVER'])
-if sys.hexversion >= 0x020400f0:
+if sys.version_info >= (2, 4):
class Py24Test(CoverageTest):
"""Tests of new syntax in Python 2.4."""
@@ -1464,7 +1464,7 @@ if sys.hexversion >= 0x020400f0:
[1,2,3,4,5,7,8,9,10,11,12,14, 17,19,21, 24,26]), "")
-if sys.hexversion >= 0x020500f0:
+if sys.version_info >= (2, 5):
class Py25Test(CoverageTest):
"""Tests of new syntax in Python 2.5."""
diff --git a/test/test_oddball.py b/test/test_oddball.py
index b102019b..a40fb4c8 100644
--- a/test/test_oddball.py
+++ b/test/test_oddball.py
@@ -245,7 +245,7 @@ class ExceptionTest(CoverageTest):
self.assertEqual(clean_lines, lines_expected)
-if sys.hexversion > 0x02050000:
+if sys.version_info >= (2, 5):
class DoctestTest(CoverageTest):
"""Tests invoked with doctest should measure properly."""