Permalink
Browse files

Removed raises function from Mote; use Expecter Gadget!

  • Loading branch information...
1 parent 8c9ce56 commit 07dba136b0fb136e53ff3987e6e4fa702737943b @garybernhardt committed Feb 19, 2010
Showing with 14 additions and 26 deletions.
  1. +7 −6 examples/integers_spec.py
  2. +7 −3 examples/urllib2_spec.py
  3. +0 −17 mote/__init__.py
View
@@ -1,20 +1,21 @@
-from mote import raises
+from __future__ import with_statement
+from expecter import expect
def describe_integer():
def describe_when_adding_one_and_one():
x = 1 + 1
def should_get_two():
assert x == 2
- def describe_when_divided_by_zero():
- def should_raise_zero_division_error():
- assert raises(ZeroDivisionError, lambda: 1 / 0)
+ def raises_error_when_dividing_by_zero():
+ with expect.raises(ZeroDivisionError):
+ 1 / 0
# Output:
#
+# integer
# integer when adding one and one
# - should get two
-# integer when divided by zero
-# - should raise zero division error
+# - raises error when dividing by zero
# OK
View
@@ -1,9 +1,11 @@
+from __future__ import with_statement
import socket
import urllib2 as mod
from urllib2 import HTTPHandler, URLError
-from mote import isolate, raises
+from mote import isolate
from dingus import Dingus, DontCare, exception_raiser
+from expecter import expect
@isolate(HTTPHandler, exclude=['URLError'])
@@ -12,7 +14,8 @@ def describe_with_no_URL():
req = Dingus(get_host__returns=None)
def raises_URL_error():
- assert raises(URLError, HTTPHandler().http_open, req)
+ with expect.raises(URLError):
+ HTTPHandler().http_open(req)
def doesnt_make_a_request():
assert not current_http_connection().calls('request')
@@ -33,7 +36,8 @@ def raises_URL_error_when_socket_error_happens():
mod.socket.error = socket.error
current_http_connection().request = exception_raiser(
mod.socket.error)
- assert raises(URLError, HTTPHandler().http_open, req)
+ with expect.raises(URLError):
+ HTTPHandler().http_open(req)
def describe_processing_a_post():
mod.splittype.return_value = Dingus.many(2)
View
@@ -1,5 +1,3 @@
-import unittest
-
from dingus import DingusTestCase
@@ -16,18 +14,3 @@ def new_fn(*args, **kwargs):
return new_fn
return decorator
-
-def raises(exception, callable_, *args, **kwargs):
- try:
- assert_raises = DummyTestCase('nop').failUnlessRaises
- assert_raises(exception, callable_, *args, **kwargs)
- except AssertionError:
- return False
- else:
- return True
-
-
-class DummyTestCase(unittest.TestCase):
- def nop(self):
- pass
-

0 comments on commit 07dba13

Please sign in to comment.