fix tests involving Queue

--HG--
branch : trunk
This commit is contained in:
Benjamin Peterson 2009-08-29 09:02:20 -05:00
parent 1dafcc6b37
commit 96ec12902d
1 changed files with 10 additions and 7 deletions

View File

@ -1,3 +1,8 @@
try:
import Queue as queue
except ImportError:
import queue
import py import py
from py.__.code.code import FormattedExcinfo, ReprExceptionInfo from py.__.code.code import FormattedExcinfo, ReprExceptionInfo
@ -232,10 +237,9 @@ def test_excinfo_no_sourcecode():
assert s == " File '<string>':1 in <module>\n ???\n" assert s == " File '<string>':1 in <module>\n ???\n"
def test_entrysource_Queue_example(): def test_entrysource_Queue_example():
import Queue
try: try:
Queue.Queue().get(timeout=0.001) queue.Queue().get(timeout=0.001)
except Queue.Empty: except queue.Empty:
excinfo = py.code.ExceptionInfo() excinfo = py.code.ExceptionInfo()
entry = excinfo.traceback[-1] entry = excinfo.traceback[-1]
source = entry.getsource() source = entry.getsource()
@ -244,15 +248,14 @@ def test_entrysource_Queue_example():
assert s.startswith("def get") assert s.startswith("def get")
def test_codepath_Queue_example(): def test_codepath_Queue_example():
import Queue
try: try:
Queue.Queue().get(timeout=0.001) queue.Queue().get(timeout=0.001)
except Queue.Empty: except queue.Empty:
excinfo = py.code.ExceptionInfo() excinfo = py.code.ExceptionInfo()
entry = excinfo.traceback[-1] entry = excinfo.traceback[-1]
path = entry.path path = entry.path
assert isinstance(path, py.path.local) assert isinstance(path, py.path.local)
assert path.basename == "Queue.py" assert path.basename.lower() == "queue.py"
assert path.check() assert path.check()
class TestFormattedExcinfo: class TestFormattedExcinfo: