Skip to content

Commit

Permalink
simplify equals tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mylokin committed Apr 11, 2015
1 parent 150394f commit 4f7c07d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
10 changes: 5 additions & 5 deletions tests/test_client.py
Expand Up @@ -14,19 +14,19 @@
class Request(unittest.TestCase):
def test_url(self):
service = servy.client.Request('localhost', 'serv')
self.assertEqual(service.url, 'http://localhost/serv')
assert service.url == 'http://localhost/serv'

def test_client_init(self):
client = servy.client.Client('localhost', 'serv')
self.assertEqual(client._Client__service.url, 'http://localhost/serv')
assert client._Client__service.url == 'http://localhost/serv'

def test_client_host_with_port(self):
client = servy.client.Client('localhost:80', 'serv')
self.assertEqual(client._Client__service.url, 'http://localhost:80/serv')
assert client._Client__service.url == 'http://localhost:80/serv'

def test_client_unicode_values(self):
client = servy.client.Client(u'localhost:80', u'serv')
self.assertEqual(client._Client__service.url, 'http://localhost:80/serv')
assert client._Client__service.url == 'http://localhost:80/serv'


class RemoteExecution(unittest.TestCase):
Expand All @@ -38,7 +38,7 @@ def test_remote_execution(self):
content = servy.proto.Response.encode('content')
with mock.patch('servy.client.Request.read') as read:
read.return_value = content
self.assertEqual(self.client.fn(), servy.proto.Response.decode(content))
assert self.client.fn() == servy.proto.Response.decode(content)
message = servy.proto.Request.encode((), {})
read.assert_called_once_with(message)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_exceptions.py
Expand Up @@ -8,4 +8,4 @@
class StringRepresentation(unittest.TestCase):
def test_service_not_found_str_repr(self):
exception = servy.exc.ServiceNotFound('serv')
self.assertEqual(str(exception), 'serv')
assert str(exception) == 'serv'
34 changes: 17 additions & 17 deletions tests/test_inspector.py
Expand Up @@ -98,56 +98,56 @@ def test_single_underscores(self):
class Analyze(unittest.TestCase):
def test_dummy_object(self):
containers, services = servy.server.Inspector.analyze(Dummy)
self.assertEqual(containers, {})
self.assertEqual(services, {'fn': Dummy.fn})
assert containers == {}
assert services == {'fn': Dummy.fn}

def test_dummy_instance_object(self):
dummy = Dummy()
containers, services = servy.server.Inspector.analyze(dummy)
self.assertEqual(containers, {})
self.assertEqual(services, {'fn': dummy.fn})
assert containers == {}
assert services == {'fn': dummy.fn}

def test_empty_object(self):
containers, services = servy.server.Inspector.analyze(Empty)
self.assertEqual(containers, {})
self.assertEqual(services, {})
assert containers == {}
assert services == {}

def test_map(self):
containers, services = servy.server.Inspector.analyze(Map)
self.assertEqual(containers, {'m': Map.m})
self.assertEqual(services, {})
assert containers == {'m': Map.m}
assert services == {}

def test_map_instance(self):
m = Map()
containers, services = servy.server.Inspector.analyze(m)
self.assertEqual(containers, {'m': m.m})
self.assertEqual(services, {})
assert containers == {'m': m.m}
assert services == {}

def test_dict(self):
container = {'fn': lambda x: x}
containers, services = servy.server.Inspector.analyze(container)
self.assertEqual(containers, {})
self.assertEqual(services, {'fn': container['fn']})
assert containers == {}
assert services == {'fn': container['fn']}


class ServiceFinder(unittest.TestCase):
def test_dummy(self):
services = servy.server.Inspector.find(Dummy)
self.assertEqual(services, {'fn': Dummy.fn})
assert services == {'fn': Dummy.fn}

def test_dummy_instance(self):
dummy = Dummy()
services = servy.server.Inspector.find(dummy)
self.assertEqual(services, {'fn': dummy.fn})
assert services == {'fn': dummy.fn}

def test_empty(self):
services = servy.server.Inspector.find(Empty)
self.assertEqual(services, {})
assert services == {}

def test_map(self):
services = servy.server.Inspector.find(Map)
self.assertEqual(services, {'m.fn': Map.m['fn']})
assert services == {'m.fn': Map.m['fn']}

def test_service(self):
services = servy.server.Inspector.find(Inception)
self.assertEqual(services, {})
assert services == {}
10 changes: 5 additions & 5 deletions tests/test_proto.py
Expand Up @@ -18,10 +18,10 @@ def test_base_class(self):

def test_encode(self):
content = servy.proto.Response.encode('content')
self.assertEqual(content, self.message)
assert content == self.message

def test_decode(self):
self.assertEqual(servy.proto.Response.decode(self.message), 'content')
assert servy.proto.Response.decode(self.message) == 'content'


class RequestProto(unittest.TestCase):
Expand All @@ -39,7 +39,7 @@ def test_base_class(self):

def test_encode(self):
content = servy.proto.Request.encode((), {})
self.assertEqual(content, self.message)
assert content == self.message

def test_decode(self):
self.assertEqual(
Expand All @@ -60,7 +60,7 @@ def test_base_class(self):

def test_encode(self):
content = servy.proto.RemoteException.encode('traceback')
self.assertEqual(content, self.message)
assert content == self.message

def test_decode(self):
self.assertEqual(servy.proto.RemoteException.decode(self.message), 'traceback')
assert servy.proto.RemoteException.decode(self.message) == 'traceback'
10 changes: 5 additions & 5 deletions tests/test_server.py
Expand Up @@ -37,7 +37,7 @@ def test_explicit_with_junk(self):
server = servy.server.Server(
junk=type,
)
self.assertEqual(server.procedures, {})
assert server.procedures == {}

def test_decorator_simple_container(self):
Server = servy.server.Server(Simple)
Expand All @@ -50,7 +50,7 @@ def test_decorator_simple_non_container(self):
class Server(object):
simple = Simple

self.assertEqual(Server.procedures, {})
assert Server.procedures == {}

def test_decorator_complex(self):
@servy.server.Server
Expand Down Expand Up @@ -82,7 +82,7 @@ def test_docs(self):
request.method = 'GET'

response = RPC(request)
self.assertEqual(response, 'proc\n None\n\nproc_ext\n None\n\n')
assert response == 'proc\n None\n\nproc_ext\n None\n\n'

def test_method_not_allowed(self):
request = webob.Request.blank('/proc')
Expand Down Expand Up @@ -111,12 +111,12 @@ def test_call_without_args(self):
request.body = proto.Request.encode((), {})

response = proto.Response.decode(RPC(request))
self.assertEqual(response, 'rpc')
assert response == 'rpc'

def test_call_with_args(self):
request = webob.Request.blank('/proc_ext')
request.method = 'POST'
request.body = proto.Request.encode(('O'), {'suffix': 'O'})

response = proto.Response.decode(RPC(request))
self.assertEqual(response, 'O_O')
assert response == 'O_O'

0 comments on commit 4f7c07d

Please sign in to comment.