1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- # -*- coding: utf-8 -*-
- import pytest
- import os
- import yaml
- import dingguo
- import datetime
- project_root_path = os.path.realpath(os.path.join(__file__, '..', '..'))
- test_data_path = os.path.join(project_root_path, 'tests', 'data')
- def get_figure_a():
- return dingguo.Figure(12.3, u'km')
- def get_figure_b():
- return dingguo.Figure(12300, u'米')
- def to_yaml(data):
- return yaml.dump(data, default_flow_style = False, allow_unicode = True).decode('utf-8')
- def test_figure_to_yaml():
- assert to_yaml(get_figure_a()) == u"""!figure
- unit: km
- value: 12.3
- """
- def test_figure_to_yaml_unicode():
- assert to_yaml(get_figure_b()) == u"""!figure
- unit: 米
- value: 12300
- """
- def test_figure_from_yaml():
- assert get_figure_a() == yaml.load(u"""!figure
- unit: km
- value: 12.3
- """)
- def test_figure_to_yaml_unicode():
- assert get_figure_b() == yaml.load(u"""!figure
- unit: 米
- value: 12300
- """)
|