summaryrefslogtreecommitdiff
path: root/_pytest/_code/code.py
diff options
context:
space:
mode:
authorRonny Pfannschmidt <ronny.pfannschmidt@redhat.com>2016-06-22 14:39:33 +0200
committerRonny Pfannschmidt <ronny.pfannschmidt@redhat.com>2016-06-22 14:39:33 +0200
commit083f64100d2b4a7074bb46b0e5c2443c5323114e (patch)
tree325c009862c93d565a6da4c74657b35243d30adc /_pytest/_code/code.py
parent4350f499b2bdf0bcc24e55787436928b021489e3 (diff)
parent24179dc99fd8d7c5196f583aedd9121441abac8e (diff)
downloadpytest-083f64100d2b4a7074bb46b0e5c2443c5323114e.tar.gz
merge master into features
Diffstat (limited to '_pytest/_code/code.py')
-rw-r--r--_pytest/_code/code.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/_pytest/_code/code.py b/_pytest/_code/code.py
index 78bd7368e..0f1ffb918 100644
--- a/_pytest/_code/code.py
+++ b/_pytest/_code/code.py
@@ -3,7 +3,6 @@ from inspect import CO_VARARGS, CO_VARKEYWORDS
import re
import py
-
builtin_repr = repr
reprlib = py.builtin._tryimport('repr', 'reprlib')
@@ -36,12 +35,16 @@ class Code(object):
def path(self):
""" return a path object pointing to source code (note that it
might not point to an actually existing file). """
- p = py.path.local(self.raw.co_filename)
- # maybe don't try this checking
- if not p.check():
+ try:
+ p = py.path.local(self.raw.co_filename)
+ # maybe don't try this checking
+ if not p.check():
+ raise OSError("py.path check failed.")
+ except OSError:
# XXX maybe try harder like the weird logic
# in the standard lib [linecache.updatecache] does?
p = self.raw.co_filename
+
return p
@property