Skip to content

Commit

Permalink
Merge pull request #163 from riptideio/dev
Browse files Browse the repository at this point in the history
preparing for pymodbus 1.3.0
  • Loading branch information
dhoomakethu authored May 12, 2017
2 parents 9517a05 + 4a1a36d commit 4afaff7
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 27 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ build/
dist/
pymodbus.egg-info/
.coverage
.vscode
.idea
.noseids
10 changes: 6 additions & 4 deletions pymodbus/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,26 @@

class Version(object):

def __init__(self, package, major, minor, micro):
def __init__(self, package, major, minor, micro, pre):
'''
:param package: Name of the package that this is a version of.
:param major: The major version number.
:param minor: The minor version number.
:param micro: The micro version number.
:param pre: The pre release tag
'''
self.package = package
self.major = major
self.minor = minor
self.micro = micro
self.pre = pre

def short(self):
''' Return a string in canonical short version format
<major>.<minor>.<micro>
<major>.<minor>.<micro>.<pre>
'''
return '%d.%d.%d' % (self.major, self.minor, self.micro)
return '%d.%d.%d.%s' % (self.major, self.minor, self.micro, self.pre)

def __str__(self):
''' Returns a string representation of the object
Expand All @@ -35,7 +37,7 @@ def __str__(self):
'''
return '[%s, version %s]' % (self.package, self.short())

version = Version('pymodbus', 1, 3, 0)
version = Version('pymodbus', 1, 3, 0, "rc1")
version.__name__ = 'pymodbus' # fix epydoc error

#---------------------------------------------------------------------------#
Expand Down
29 changes: 16 additions & 13 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
# -------------------------------------------------------------------
# if want to use the pymodbus serial stack, uncomment these
# -------------------------------------------------------------------
#pyserial==2.6
#pyserial==3.3
# -------------------------------------------------------------------
# if you want to run the tests and code coverage, uncomment these
# -------------------------------------------------------------------
#coverage==3.5.3
#mock==1.0b1
#nose==1.2.1
#pep8==1.3.3
#coverage==4.4
#mock==2.0.0
#nose==1.3.7
#pep8==1.7.0
# -------------------------------------------------------------------
# if you want to use the asynchronous version, uncomment these
# -------------------------------------------------------------------
#Twisted==12.2.0
#zope.interface==4.0.1
#pyasn1==0.1.4
#pycrypto==2.6
#Twisted==17.1.0
#zope.interface==4.4.0
#pyasn1==0.2.3
#pycrypto==2.6.1
#wsgiref==0.1.2
#cryptography==1.8.1
# -------------------------------------------------------------------
# if you want to build the documentation, uncomment these
# -------------------------------------------------------------------
#Jinja2==2.6
#Pygments==1.5
#Sphinx==1.1.3
#docutils==0.9.1
#Jinja2==2.9.6
#Pygments==2.2.0
#Sphinx==1.5.5
#docutils==0.13.1
#pydoctor==16.3.0

4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
author = __author__,
author_email = '[email protected]',
maintainer = __author__,
maintainer_email = 'bashwork@gmail.com',
url='http://code.google.com/p/pymodbus/',
maintainer_email = 'otlasanju@gmail.com',
url='https://github.com/riptideio/pymodbus/',
license = 'BSD',
packages = find_packages(exclude=['examples', 'test']),
exclude_package_data = {'' : ['examples', 'test', 'tools', 'doc']},
Expand Down
12 changes: 8 additions & 4 deletions test/test_server_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
from pymodbus.server.async import ModbusTcpProtocol, ModbusUdpProtocol
from pymodbus.server.async import ModbusServerFactory
from pymodbus.server.async import StartTcpServer, StartUdpServer, StartSerialServer
from pymodbus.exceptions import ConnectionException, NotImplementedException
from pymodbus.exceptions import ParameterException
from pymodbus.bit_read_message import ReadCoilsRequest, ReadCoilsResponse


import sys
#---------------------------------------------------------------------------#
# Fixture
#---------------------------------------------------------------------------#
SERIAL_PORT = "/dev/ptmx"
if sys.platform == "darwin":
SERIAL_PORT = "/dev/ptyp0"


class AsynchronousServerTest(unittest.TestCase):
'''
This is the unittest for the pymodbus.server.async module
Expand Down Expand Up @@ -84,7 +88,7 @@ def testUdpServerStartup(self):
def testSerialServerStartup(self):
''' Test that the modbus serial async server starts correctly '''
with patch('twisted.internet.reactor') as mock_reactor:
StartSerialServer(context=None, port='/dev/ptmx')
StartSerialServer(context=None, port=SERIAL_PORT)
self.assertEqual(mock_reactor.run.call_count, 1)

#---------------------------------------------------------------------------#
Expand Down
6 changes: 5 additions & 1 deletion test/test_server_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
from pymodbus.server.sync import StartTcpServer, StartUdpServer, StartSerialServer
from pymodbus.exceptions import NotImplementedException
from pymodbus.bit_read_message import ReadCoilsRequest, ReadCoilsResponse
import sys

SERIAL_PORT = "/dev/ptmx"
if sys.platform == "darwin":
SERIAL_PORT = "/dev/ptyp0"
#---------------------------------------------------------------------------#
# Mock Classes
#---------------------------------------------------------------------------#
Expand Down Expand Up @@ -322,7 +326,7 @@ def testStartUdpServer(self):
def testStartSerialServer(self):
''' Test the serial server starting factory '''
with patch.object(ModbusSerialServer, 'serve_forever') as mock_server:
StartSerialServer()
StartSerialServer(port=SERIAL_PORT)

#---------------------------------------------------------------------------#
# Main
Expand Down
7 changes: 4 additions & 3 deletions test/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ def tearDown(self):
pass

def testVersionClass(self):
version = Version('test', 1,2,3)
self.assertEqual(version.short(), '1.2.3')
self.assertEqual(str(version), '[test, version 1.2.3]')
version = Version('test', 1,2,3, "sometag")
short = version.short()
self.assertEqual(version.short(), '1.2.3.sometag')
self.assertEqual(str(version), '[test, version 1.2.3.sometag]')

#---------------------------------------------------------------------------#
# Main
Expand Down

0 comments on commit 4afaff7

Please sign in to comment.