Skip to content
This repository has been archived by the owner on Sep 27, 2021. It is now read-only.

Commit

Permalink
Move test code into unittest framework
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Sep 12, 2016
1 parent 0452ee4 commit 943f688
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
25 changes: 25 additions & 0 deletions nnpy/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from __future__ import print_function
import nnpy, unittest

class Tests(unittest.TestCase):
def test_basic(self):

pub = nnpy.Socket(nnpy.AF_SP, nnpy.PUB)
pub.bind('inproc://foo')
self.assertEqual(pub.getsockopt(nnpy.SOL_SOCKET, nnpy.DOMAIN), 1)

sub = nnpy.Socket(nnpy.AF_SP, nnpy.SUB)
sub.connect('inproc://foo')
sub.setsockopt(nnpy.SUB, nnpy.SUB_SUBSCRIBE, '')

pub.send('FLUB')
poller = nnpy.PollSet((sub, nnpy.POLLIN))
self.assertEqual(poller.poll(), 1)
self.assertEqual(sub.recv(), 'FLUB')
self.assertEqual(pub.get_statistic(nnpy.STAT_MESSAGES_SENT), 1)

def suite():
return unittest.makeSuite(Tests)

if __name__ == '__main__':
unittest.main(defaultTest='suite')
16 changes: 0 additions & 16 deletions test.py

This file was deleted.

0 comments on commit 943f688

Please sign in to comment.