Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix Windows compatibility.

  • Loading branch information...
commit f903f3d0c66701eae1cfa81c7173d95db120fbc7 1 parent 0423364
@cortesi authored
View
2  libpry/coverage.py
@@ -29,7 +29,7 @@ def nicePath(self, base):
else:
common = len(os.path.commonprefix([base, self.path]))
fname = self.path[common:]
- if fname[0] == "/":
+ if fname[0] in os.path.sep:
fname = fname[1:]
return fname
View
13 libpry/utils.py
@@ -1,4 +1,4 @@
-import os.path, fnmatch, struct, fcntl, termios, os
+import os.path, fnmatch, struct, os
def summariseList(lst):
"""
@@ -108,10 +108,11 @@ def _splitSpec(spec):
# begin nocover
def terminalWidth():
+ width = None
try:
+ import fcntl, termios
cr = struct.unpack('hh', fcntl.ioctl(0, termios.TIOCGWINSZ, '1234'))
- except IOError:
- cr = None
- if not cr:
- return 80
- return int(cr[1])
+ width = int(cr[1])
+ except (IOError, ImportError):
+ pass
+ return width or 80
View
10 test/test_coverage.py
@@ -73,18 +73,18 @@ def test_init(self):
def test_nicePath(self):
f = libpry.coverage.File(None)
- f.path = "/foo/bar.py"
- assert f.nicePath("/foo") == "bar.py"
+ f.path = os.path.sep[0] + os.path.join("foo", "bar.py")
+ assert f.nicePath(os.path.sep[0] + "foo") == "bar.py"
assert f.nicePath(f.path) == "bar.py"
def test_cmp(self):
- f1 = libpry.coverage.File("testmodule/test_a.py")
- f2 = libpry.coverage.File("testmodule/test_a.py")
+ f1 = libpry.coverage.File(os.path.join("testmodule", "test_a.py"))
+ f2 = libpry.coverage.File(os.path.join("testmodule", "test_a.py"))
f1.executed.add(f1.executable.pop())
assert cmp(f1, f2)
def test_annotated(self):
- f = libpry.coverage.File("testmodule/test_a.py")
+ f = libpry.coverage.File(os.path.join("testmodule", "test_a.py"))
assert f.getAnnotation()
def test_stats(self):
View
8 test/test_test.py
@@ -432,13 +432,13 @@ def test_init(self):
r = libpry.test._RootNode(False, None)
r.addPath("testmodule", True)
assert r.search("test_one")
- assert r.search("testmodule/test_a.uOne.test_one")
- assert r.search("testmodule/two/test_two")
+ assert r.search(os.path.join("testmodule", "test_a.uOne.test_one"))
+ assert r.search(os.path.join("testmodule", "two", "test_two"))
assert not r.search("nonexistent")
r = libpry.test._RootNode(False, None)
r.addPath("testmodule", False)
- assert not r.search("testmodule/two/test_two")
+ assert not r.search(os.path.join("testmodule", "two", "test_two"))
assert r.search("test_one")
def test_errFinal(self):
@@ -543,7 +543,7 @@ def test_construct(self):
class u_FileNode(libpry.test.AutoTree):
def test_repr(self):
- n = self["root"].search("testmodule/test_a")[0]
+ n = self["root"].search(os.path.join("testmodule", "test_a"))[0]
repr(n)
Please sign in to comment.
Something went wrong with that request. Please try again.