Skip to content

Commit a033aa4

Browse files
committed
bugfix
1 parent 535e70c commit a033aa4

File tree

5 files changed

+36
-7
lines changed

5 files changed

+36
-7
lines changed

Makefile

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
send_package:
2-
python setup.py sdist bdist_wheel
3-
twine upload dist/*
2+
python setup.py sdist bdist_wheel
3+
twine upload dist/*
44

55
clean:
66
find . -name '*.pyc' -delete
77
ptyhon setup.py clean --all
88
rm -rf pyconst.egg-info
99
rm -rf dist
10+
11+
test:
12+
pytest tests -vsrx
13+
14+
coverage:
15+
pytest tests -vsrx --cov=pyconst --cov-report html
16+

pyconst/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# encoding: utf-8
22
from __future__ import unicode_literals, absolute_import
33

4-
__version__ = (1, 0, 5)
4+
__version__ = (1, 0, 6)
55
__author__ = '[email protected]'
66

77
from .const import Const

pyconst/const.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ def __set_iter_value(self, iter_value):
2929
elif len(iter_value) == 2:
3030
label, attr = iter_value
3131
elif len(iter_value) == 3:
32-
label, attr, value = label
32+
label, attr, value = iter_value
3333
elif len(iter_value) > 3:
34-
attr = label[1]
35-
value = label[2]
36-
label = label[0]
34+
attr = iter_value[1]
35+
value = iter_value[2]
36+
label = iter_value[0]
3737
return label, attr, value
3838

3939
def add(self, label, attr=None, value=None):

tests/test_pycont.py

+14
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,20 @@ def test_set_different_attribute_and_value(self):
9191
self.assertEqual(const[0], ('1', u'First item'))
9292
self.assertEqual(const.my_item, '1')
9393

94+
def test_set_const_with_tuple_three_values(self):
95+
const = Const(('Label Test', 'Attr test', 'Value test'),
96+
('Label Test2', 'Attr test2', 'Value test2'),)
97+
98+
self.assertEqual(const[0], ('value_test', u'Label Test'))
99+
self.assertEqual(const.attr_test, 'value_test')
100+
101+
def test_set_const_with_tuple_four_values(self):
102+
const = Const(('Label Test', 'Attr test', 'Value test', 'Ignore Value'),
103+
('Label Test2', 'Attr test2', 'Value test2', 'Ignore Value'),)
104+
105+
self.assertEqual(const[0], ('value_test', u'Label Test'))
106+
self.assertEqual(const.attr_test, 'value_test')
107+
94108

95109
if __name__ == '__main__':
96110
unittest.main()

tests/test_setup.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import pyconst
2+
3+
4+
def test_get_version():
5+
# (1, 0, 5)
6+
version = pyconst.__version__
7+
str_version = '.'.join(map(str, version))
8+
assert pyconst.get_version() == str_version

0 commit comments

Comments
 (0)