Fix for upstream changes in kj::Exception
* Change from using Nature/Durability to Type * Prefer to raise KjException directly instead of Value/RuntimError. * Will still raise AttributeError appropriately.
This commit is contained in:
@@ -32,7 +32,7 @@ class PipelineServer(capability.TestPipeline.Server):
|
||||
|
||||
def test_client():
|
||||
client = capability.TestInterface._new_client(Server())
|
||||
|
||||
|
||||
req = client._request('foo')
|
||||
req.i = 5
|
||||
|
||||
@@ -40,7 +40,7 @@ def test_client():
|
||||
response = remote.wait()
|
||||
|
||||
assert response.x == '26'
|
||||
|
||||
|
||||
req = client.foo_request()
|
||||
req.i = 5
|
||||
|
||||
@@ -54,7 +54,7 @@ def test_client():
|
||||
|
||||
req = client.foo_request()
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
req.i = 'foo'
|
||||
|
||||
req = client.foo_request()
|
||||
@@ -64,18 +64,18 @@ def test_client():
|
||||
|
||||
def test_simple_client():
|
||||
client = capability.TestInterface._new_client(Server())
|
||||
|
||||
|
||||
remote = client._send('foo', i=5)
|
||||
response = remote.wait()
|
||||
|
||||
assert response.x == '26'
|
||||
|
||||
|
||||
|
||||
remote = client.foo(i=5)
|
||||
response = remote.wait()
|
||||
|
||||
assert response.x == '26'
|
||||
|
||||
|
||||
remote = client.foo(i=5, j=True)
|
||||
response = remote.wait()
|
||||
|
||||
@@ -107,19 +107,19 @@ def test_simple_client():
|
||||
assert response.x == '5_test'
|
||||
assert response.i == 5
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
remote = client.foo(5, 10)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
remote = client.foo(5, True, 100)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
remote = client.foo(i='foo')
|
||||
|
||||
with pytest.raises(AttributeError):
|
||||
remote = client.foo2(i=5)
|
||||
|
||||
with pytest.raises(AttributeError):
|
||||
with pytest.raises(Exception):
|
||||
remote = client.foo(baz=5)
|
||||
|
||||
def test_pipeline():
|
||||
@@ -149,7 +149,7 @@ class BadServer(capability.TestInterface.Server):
|
||||
|
||||
def test_exception_client():
|
||||
client = capability.TestInterface._new_client(BadServer())
|
||||
|
||||
|
||||
remote = client._send('foo', i=5)
|
||||
with pytest.raises(capnp.KjException):
|
||||
remote.wait()
|
||||
@@ -267,7 +267,7 @@ def test_cancel():
|
||||
remote = req.send()
|
||||
remote.cancel()
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
remote.wait()
|
||||
|
||||
|
||||
@@ -301,32 +301,32 @@ def test_double_send():
|
||||
req.i = 5
|
||||
|
||||
req.send()
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
req.send()
|
||||
|
||||
|
||||
def test_then_args():
|
||||
capnp.Promise(0).then(lambda x: 1)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
capnp.Promise(0).then(lambda: 1)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
capnp.Promise(0).then(lambda x, y: 1)
|
||||
|
||||
capnp.getTimer().after_delay(1).then(lambda: 1) # after_delay is a VoidPromise
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
capnp.getTimer().after_delay(1).then(lambda x: 1)
|
||||
|
||||
client = capability.TestInterface._new_client(Server())
|
||||
|
||||
client.foo(i=5).then(lambda x: 1)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
client.foo(i=5).then(lambda: 1)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
client.foo(i=5).then(lambda x, y: 1)
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class PipelineServer:
|
||||
|
||||
def test_client_context(capability):
|
||||
client = capability.TestInterface._new_client(Server())
|
||||
|
||||
|
||||
req = client._request('foo')
|
||||
req.i = 5
|
||||
|
||||
@@ -39,7 +39,7 @@ def test_client_context(capability):
|
||||
response = remote.wait()
|
||||
|
||||
assert response.x == '26'
|
||||
|
||||
|
||||
req = client.foo_request()
|
||||
req.i = 5
|
||||
|
||||
@@ -53,7 +53,7 @@ def test_client_context(capability):
|
||||
|
||||
req = client.foo_request()
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
req.i = 'foo'
|
||||
|
||||
req = client.foo_request()
|
||||
@@ -63,18 +63,18 @@ def test_client_context(capability):
|
||||
|
||||
def test_simple_client_context(capability):
|
||||
client = capability.TestInterface._new_client(Server())
|
||||
|
||||
|
||||
remote = client._send('foo', i=5)
|
||||
response = remote.wait()
|
||||
|
||||
assert response.x == '26'
|
||||
|
||||
|
||||
|
||||
remote = client.foo(i=5)
|
||||
response = remote.wait()
|
||||
|
||||
assert response.x == '26'
|
||||
|
||||
|
||||
remote = client.foo(i=5, j=True)
|
||||
response = remote.wait()
|
||||
|
||||
@@ -100,19 +100,19 @@ def test_simple_client_context(capability):
|
||||
|
||||
assert response.x == 'localhost_test'
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
remote = client.foo(5, 10)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
remote = client.foo(5, True, 100)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
remote = client.foo(i='foo')
|
||||
|
||||
with pytest.raises(AttributeError):
|
||||
remote = client.foo2(i=5)
|
||||
|
||||
with pytest.raises(AttributeError):
|
||||
with pytest.raises(Exception):
|
||||
remote = client.foo(baz=5)
|
||||
|
||||
def test_pipeline_context(capability):
|
||||
@@ -140,7 +140,7 @@ class BadServer:
|
||||
|
||||
def test_exception_client_context(capability):
|
||||
client = capability.TestInterface._new_client(BadServer())
|
||||
|
||||
|
||||
remote = client._send('foo', i=5)
|
||||
with pytest.raises(capnp.KjException):
|
||||
remote.wait()
|
||||
|
||||
@@ -32,7 +32,7 @@ class PipelineServer:
|
||||
|
||||
def test_client(capability):
|
||||
client = capability.TestInterface._new_client(Server())
|
||||
|
||||
|
||||
req = client._request('foo')
|
||||
req.i = 5
|
||||
|
||||
@@ -40,7 +40,7 @@ def test_client(capability):
|
||||
response = remote.wait()
|
||||
|
||||
assert response.x == '26'
|
||||
|
||||
|
||||
req = client.foo_request()
|
||||
req.i = 5
|
||||
|
||||
@@ -54,7 +54,7 @@ def test_client(capability):
|
||||
|
||||
req = client.foo_request()
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
req.i = 'foo'
|
||||
|
||||
req = client.foo_request()
|
||||
@@ -64,18 +64,18 @@ def test_client(capability):
|
||||
|
||||
def test_simple_client(capability):
|
||||
client = capability.TestInterface._new_client(Server())
|
||||
|
||||
|
||||
remote = client._send('foo', i=5)
|
||||
response = remote.wait()
|
||||
|
||||
assert response.x == '26'
|
||||
|
||||
|
||||
|
||||
remote = client.foo(i=5)
|
||||
response = remote.wait()
|
||||
|
||||
assert response.x == '26'
|
||||
|
||||
|
||||
remote = client.foo(i=5, j=True)
|
||||
response = remote.wait()
|
||||
|
||||
@@ -101,19 +101,19 @@ def test_simple_client(capability):
|
||||
|
||||
assert response.x == 'localhost_test'
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
remote = client.foo(5, 10)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
remote = client.foo(5, True, 100)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
remote = client.foo(i='foo')
|
||||
|
||||
with pytest.raises(AttributeError):
|
||||
remote = client.foo2(i=5)
|
||||
|
||||
with pytest.raises(AttributeError):
|
||||
with pytest.raises(Exception):
|
||||
remote = client.foo(baz=5)
|
||||
|
||||
def test_pipeline(capability):
|
||||
@@ -143,7 +143,7 @@ class BadServer:
|
||||
|
||||
def test_exception_client(capability):
|
||||
client = capability.TestInterface._new_client(BadServer())
|
||||
|
||||
|
||||
remote = client._send('foo', i=5)
|
||||
with pytest.raises(capnp.KjException):
|
||||
remote.wait()
|
||||
@@ -249,4 +249,4 @@ def test_tail_call(capability):
|
||||
assert result.n == 2
|
||||
|
||||
assert callee_server.count == 1
|
||||
assert caller_server.count == 1
|
||||
assert caller_server.count == 1
|
||||
|
||||
@@ -52,7 +52,7 @@ def test_failed_import():
|
||||
|
||||
foo.name = 'foo'
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
bar.foo = foo
|
||||
|
||||
def test_defualt_import_hook():
|
||||
|
||||
@@ -37,9 +37,9 @@ def test_which_builder(addressbook):
|
||||
assert bob.employment.which == addressbook.Person.Employment.unemployed
|
||||
assert bob.employment.which == "unemployed"
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
addresses.which
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
addresses.which
|
||||
|
||||
|
||||
@@ -71,9 +71,9 @@ def test_which_reader(addressbook):
|
||||
bob = people[1]
|
||||
assert bob.employment.which == "unemployed"
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
addresses.which
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(Exception):
|
||||
addresses.which
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user