[PATCH] move all py.test imports into try/except clause (#1210)

1 view
Skip to first unread message

Ondrej Certik

unread,
Nov 21, 2008, 5:14:58 AM11/21/08
to sympy-...@googlegroups.com, Ondrej Certik
This is important, because the new py.test breaks sympy (import py works, but
not the later imports). This patch should fix it.
---
sympy/utilities/pytest.py | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/sympy/utilities/pytest.py b/sympy/utilities/pytest.py
index 5919697..c321b5f 100644
--- a/sympy/utilities/pytest.py
+++ b/sympy/utilities/pytest.py
@@ -6,7 +6,10 @@
import sys

try:
- import py
+ # tested with py-lib 0.9.0
+ from py.__.test.outcome import Outcome, Passed, Failed, Skipped
+ from py.__.test.terminal.terminal import TerminalSession
+ from py.test import skip
disabled = False
except ImportError:
disabled = True
@@ -43,11 +46,7 @@ if disabled:
def skip(str):
raise Skipped(str)
else:
- # tested with py-lib 0.9.0
- from py.__.test.outcome import Outcome, Passed, Failed, Skipped
- from py.__.test.terminal.terminal import TerminalSession
from time import time as now
- from py.test import skip

__all__ = ['XFAIL']

--
1.5.6.5

Ondrej Certik

unread,
Nov 23, 2008, 2:16:02 PM11/23/08
to sympy-...@googlegroups.com

Any comments to this?


Ondrej

Fabian Seoane

unread,
Nov 23, 2008, 2:41:23 PM11/23/08
to sympy-...@googlegroups.com, Ondrej Certik


It's fine, but I would suggest putting a print statement inside the
except bloc, something like "print 'Could not load pylib, using built-in
test lib instead. Having pylib is greatly recommended etc.'"

Also, would be nice to give the disabled variable a more meaningful
name, something like USE_PYLIB

Fabian Seoane

unread,
Nov 25, 2008, 6:40:36 AM11/25/08
to sympy-...@googlegroups.com
I attach a reworked patch with my comments plus a small fix that let's you run python setup.py test even if you don't have pylib installed.

2008/11/23 Fabian Seoane <fabian...@gmail.com>



--
Fabian, http://fseoane.net/blog/
0001-move-all-py.test-imports-into-try-except-clause-12.patch
Reply all
Reply to author
Forward
0 new messages