aboutsummaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-06-14 09:52:40 -0500
committerBenjamin Peterson <benjamin@python.org>2011-06-14 09:52:40 -0500
commitcdccc0c4fdbd74289c420070e727f5805f0d7251 (patch)
tree262b4195dfecd78665677f3845bbd00d84a6c935 /py
parentmerge heads (diff)
downloadpypy-cdccc0c4fdbd74289c420070e727f5805f0d7251.tar.gz
pypy-cdccc0c4fdbd74289c420070e727f5805f0d7251.tar.bz2
pypy-cdccc0c4fdbd74289c420070e727f5805f0d7251.zip
drag py/bin/py.test back from the graveyard
Diffstat (limited to 'py')
-rw-r--r--py/bin/_findpy.py38
-rwxr-xr-xpy/bin/py.test3
2 files changed, 41 insertions, 0 deletions
diff --git a/py/bin/_findpy.py b/py/bin/_findpy.py
new file mode 100644
index 0000000000..92b14b6c5a
--- /dev/null
+++ b/py/bin/_findpy.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+
+#
+# find and import a version of 'py'
+#
+import sys
+import os
+from os.path import dirname as opd, exists, join, basename, abspath
+
+def searchpy(current):
+ while 1:
+ last = current
+ initpy = join(current, '__init__.py')
+ if not exists(initpy):
+ pydir = join(current, 'py')
+ # recognize py-package and ensure it is importable
+ if exists(pydir) and exists(join(pydir, '__init__.py')):
+ #for p in sys.path:
+ # if p == current:
+ # return True
+ if current != sys.path[0]: # if we are already first, then ok
+ sys.stderr.write("inserting into sys.path: %s\n" % current)
+ sys.path.insert(0, current)
+ return True
+ current = opd(current)
+ if last == current:
+ return False
+
+if not searchpy(abspath(os.curdir)):
+ if not searchpy(opd(abspath(sys.argv[0]))):
+ if not searchpy(opd(__file__)):
+ pass # let's hope it is just on sys.path
+
+import py
+import pytest
+
+if __name__ == '__main__':
+ print ("py lib is at %s" % py.__file__)
diff --git a/py/bin/py.test b/py/bin/py.test
new file mode 100755
index 0000000000..8ecba0e406
--- /dev/null
+++ b/py/bin/py.test
@@ -0,0 +1,3 @@
+#!/usr/bin/env python
+from _findpy import pytest
+raise SystemExit(pytest.main())