Skip to content

Commit

Permalink
Added unit test for OneShotServer. Fixed #343
Browse files Browse the repository at this point in the history
  • Loading branch information
comrumino committed Jul 27, 2019
1 parent 6027430 commit d4445a1
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/test_oneshot_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import time
import rpyc
from rpyc.utils.server import OneShotServer
import unittest


class MyService(rpyc.Service):

def exposed_foo(self):
return "bar"


class Test_OneShotServer(unittest.TestCase):

def setUp(self):
self.server = OneShotServer(MyService, port=18878, auto_register=False)
self.server.logger.quiet = False
self.server._start_in_thread()

def tearDown(self):
self.server.close()

def test_server_stops(self):
conn = rpyc.connect("localhost", port=18878)
self.assertEqual("bar", conn.root.foo())
conn.close()
with self.assertRaises(Exception):
for i in range(3):
conn = rpyc.connect("localhost", port=18878)
conn.close()
time.sleep()


if __name__ == "__main__":
unittest.main()

0 comments on commit d4445a1

Please sign in to comment.