Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
valdergallo committed Nov 6, 2016
1 parent 535e70c commit a033aa4
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 7 deletions.
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
send_package:
python setup.py sdist bdist_wheel
twine upload dist/*
python setup.py sdist bdist_wheel
twine upload dist/*

clean:
find . -name '*.pyc' -delete
ptyhon setup.py clean --all
rm -rf pyconst.egg-info
rm -rf dist

test:
pytest tests -vsrx

coverage:
pytest tests -vsrx --cov=pyconst --cov-report html

2 changes: 1 addition & 1 deletion pyconst/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# encoding: utf-8
from __future__ import unicode_literals, absolute_import

__version__ = (1, 0, 5)
__version__ = (1, 0, 6)
__author__ = 'valdergallo@gmail.com'

from .const import Const
Expand Down
8 changes: 4 additions & 4 deletions pyconst/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ def __set_iter_value(self, iter_value):
elif len(iter_value) == 2:
label, attr = iter_value
elif len(iter_value) == 3:
label, attr, value = label
label, attr, value = iter_value
elif len(iter_value) > 3:
attr = label[1]
value = label[2]
label = label[0]
attr = iter_value[1]
value = iter_value[2]
label = iter_value[0]
return label, attr, value

def add(self, label, attr=None, value=None):
Expand Down
14 changes: 14 additions & 0 deletions tests/test_pycont.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ def test_set_different_attribute_and_value(self):
self.assertEqual(const[0], ('1', u'First item'))
self.assertEqual(const.my_item, '1')

def test_set_const_with_tuple_three_values(self):
const = Const(('Label Test', 'Attr test', 'Value test'),
('Label Test2', 'Attr test2', 'Value test2'),)

self.assertEqual(const[0], ('value_test', u'Label Test'))
self.assertEqual(const.attr_test, 'value_test')

def test_set_const_with_tuple_four_values(self):
const = Const(('Label Test', 'Attr test', 'Value test', 'Ignore Value'),
('Label Test2', 'Attr test2', 'Value test2', 'Ignore Value'),)

self.assertEqual(const[0], ('value_test', u'Label Test'))
self.assertEqual(const.attr_test, 'value_test')


if __name__ == '__main__':
unittest.main()
8 changes: 8 additions & 0 deletions tests/test_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import pyconst


def test_get_version():
# (1, 0, 5)
version = pyconst.__version__
str_version = '.'.join(map(str, version))
assert pyconst.get_version() == str_version

0 comments on commit a033aa4

Please sign in to comment.