From a033aa43dea1fe546931e386e8190ce5257c2508 Mon Sep 17 00:00:00 2001 From: Valder Gallo Date: Sun, 6 Nov 2016 10:16:36 -0200 Subject: [PATCH] bugfix --- Makefile | 11 +++++++++-- pyconst/__init__.py | 2 +- pyconst/const.py | 8 ++++---- tests/test_pycont.py | 14 ++++++++++++++ tests/test_setup.py | 8 ++++++++ 5 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 tests/test_setup.py diff --git a/Makefile b/Makefile index c59b5ae..8972b96 100644 --- a/Makefile +++ b/Makefile @@ -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 + diff --git a/pyconst/__init__.py b/pyconst/__init__.py index 8229d70..6eaad01 100644 --- a/pyconst/__init__.py +++ b/pyconst/__init__.py @@ -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 diff --git a/pyconst/const.py b/pyconst/const.py index 4fce009..b8e8128 100644 --- a/pyconst/const.py +++ b/pyconst/const.py @@ -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): diff --git a/tests/test_pycont.py b/tests/test_pycont.py index b3964e7..f914536 100644 --- a/tests/test_pycont.py +++ b/tests/test_pycont.py @@ -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() diff --git a/tests/test_setup.py b/tests/test_setup.py new file mode 100644 index 0000000..a39116e --- /dev/null +++ b/tests/test_setup.py @@ -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