예제 #1
0
    def test_basic(self):
        backend = MockBackend()
        server = Server(backend, 'tcp://127.0.0.1:31338')
        client = Client('tcp://127.0.0.1:31338')

        try:
            server.start()
            # This test is screwy. If simplejson is installed, it will convert
            # all strings to str objects. Without it, you get unicode objects.
            # We require simplejson so assume it's gonna be str.
            self.assertEqual(client.foo(4, 'blah'), "foo: 4 'blah'")
            self.assertEqual(
                client.bar('hello', 'world', **dict(a=12, b='blah')),
                "bar: ('hello', 'world') {'a': 12, 'b': 'blah'}")

            with self.assertRaisesRegexp(ServerError, 'ValueError: sad'):
                client.failme(42)
        finally:
            server.kill()
예제 #2
0
    def test_basic(self):
        backend = MockBackend()
        server = Server(backend, 'tcp://127.0.0.1:31338')
        client = Client('tcp://127.0.0.1:31338')

        try:
            server.start()
            # This test is screwy. If simplejson is installed, it will convert
            # all strings to str objects. Without it, you get unicode objects.
            # We require simplejson so assume it's gonna be str.
            self.assertEqual(client.foo(4, 'blah'), "foo: 4 'blah'")
            self.assertEqual(
                client.bar('hello', 'world', **dict(a=12, b='blah')),
                "bar: ('hello', 'world') {'a': 12, 'b': 'blah'}")

            with self.assertRaisesRegexp(ServerError, 'ValueError: sad'):
                client.failme(42)
        finally:
            server.kill()
예제 #3
0
 def test_timeout(self):
     client = Client('tcp://127.0.0.1:31339', wait=10)
     with self.assertRaisesRegexp(TimeoutError,
                                  'Timed out after 10 ms waiting'):
         client.foo()
예제 #4
0
 def test_timeout(self):
     client = Client('tcp://127.0.0.1:31339', wait=10)
     with self.assertRaisesRegexp(TimeoutError,
                                  'Timed out after 10 ms waiting'):
         client.foo()