123456789101112131415161718192021222324252627 |
- import pytest
- import dingguo
- @pytest.mark.parametrize(('params', 'kwargs', 'expected_value', 'expected_unit'), [
- [[1, u'cm'], {}, 1, u'cm'],
- [[1], {'unit': u'cm'}, 1, u'cm'],
- [[], {'unit': u'cm'}, None, u'cm'],
- [[], {'value': 1.0, 'unit': u'cm'}, 1.0, u'cm'],
- [[], {'value': (3, -1), 'unit': u'cm'}, (3, -1), u'cm'],
- [[(-1, 3), u'cm'], {}, (-1, 3), u'cm'],
- ])
- def test_init(params, kwargs, expected_value, expected_unit):
- f = dingguo.Figure(*params, **kwargs)
- assert type(f.value) == type(expected_value)
- assert type(f.unit) == type(expected_unit)
- assert f.value == expected_value
- assert f.unit == expected_unit
- @pytest.mark.parametrize(('params', 'kwargs'), [
- [[], {}],
- [[1, 'cm'], {}],
- [[1], {'unit': 'cm'}],
- ])
- def test_init_fail(params, kwargs):
- with pytest.raises(Exception):
- dingguo.Figure(*params, **kwargs)
|