| 
					
				 | 
			
			
				@@ -3,6 +3,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import pytest 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import os 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import pytz 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import yaml 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import dingguo 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import difflib 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -32,6 +33,18 @@ def get_item_b(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             price_brutto = get_sum_b(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+def get_person_a(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return dingguo.Person( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        first_name = u'Fabian Peter', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        last_name = u'Hammerle', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+def get_person_b(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return dingguo.Person( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        first_name = u'名字', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        last_name = u'贵姓', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 def get_article(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return dingguo.Article( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             authors = ['a', 'b'], 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -56,6 +69,8 @@ def get_transportation(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             departure_point = u'home', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             destination_point = u'city', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             distance = dingguo.Distance(3.21, u'km'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            passenger = get_person_a(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            valid_from = datetime.datetime(2016, 7, 14, 13, 50, 4, 0, tzinfo = pytz.timezone('Europe/Vienna')),  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 def get_taxi_ride(): 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -66,8 +81,8 @@ def get_taxi_ride(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             destination_point = u'city', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             distance = dingguo.Distance(3.21, u'km'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             driver = u'driver', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            arrival_time = datetime.datetime(2016, 5, 2, 18, 10), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            departure_time = datetime.datetime(2016, 5, 2, 18, 25), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            arrival_time = datetime.datetime(2016, 5, 2, 18, 10, tzinfo = pytz.timezone('Europe/Vienna')), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            departure_time = datetime.datetime(2016, 5, 2, 18, 25, tzinfo = pytz.timezone('Europe/Vienna')), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 def get_discount_a(): 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -133,95 +148,23 @@ def yaml_diff(a, b): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         to_yaml(b).split('\n'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         )) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-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 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-""") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def test_sum_to_yaml_a(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    assert to_yaml(get_sum_a()) == u"!sum '1.23 EUR'\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def test_sum_to_yaml_b(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    assert to_yaml(get_sum_b()) == u"!sum '20.45 EUR'\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def test_sum_from_yaml_a(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    assert get_sum_a() == yaml.load(u"!sum 1.23 EUR") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def test_sum_from_yaml_a_sign(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    assert get_sum_a() == yaml.load(u"!sum 1.23 €") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def test_sum_from_yaml_a_quotes(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    assert get_sum_a() == yaml.load(u"!sum '1.23 EUR'") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def test_item_to_yaml_a(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    assert to_yaml(get_item_a()) == u"""!item 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-name: item a 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-price_brutto: !sum '1.23 EUR' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-""" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def test_item_to_yaml_b(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    assert to_yaml(get_item_b()) == u"""!item 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-name: item β 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-price_brutto: !sum '20.45 EUR' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-""" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def test_item_from_yaml_a(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    assert get_item_a() == yaml.load(u"""!item 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-name: item a 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-price_brutto: !sum '1.23 EUR' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-""") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def test_item_from_yaml_b(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    assert get_item_b() == yaml.load(u"""!item 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-name: item β 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-price_brutto: !sum '20.45 EUR' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-""") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def test_discount_to_yaml_a(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    assert to_yaml(get_discount_a()) == u"""!discount 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-amount: !sum '1.23 EUR' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-name: discount a 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-""" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def test_discount_to_yaml_b(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    assert to_yaml(get_discount_b()) == u"""!discount 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-amount: !sum '20.45 EUR' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-name: discount β 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-""" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def test_discount_from_yaml_a(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    assert get_discount_a() == yaml.load(u"""!discount 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-name: discount a 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-amount: !sum '1.23 EUR' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-""") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def test_discount_from_yaml_b(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    assert get_discount_b() == yaml.load(u"""!discount 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-name: discount β 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-amount: !sum '20.45 EUR' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-""") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def test_order_to_yaml(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    assert to_yaml(get_order_a()) == u"""!order 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@pytest.mark.parametrize('source_object,expected_yaml', [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [datetime.datetime(2016, 7, 14, 13, 50, 4, 0), '2016-07-14 13:50:04\n...\n'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [datetime.datetime(2016, 7, 14, 13, 50, 4, 0, tzinfo = pytz.timezone('Europe/Vienna')), '2016-07-14 13:50:04+01:05\n...\n'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [datetime.datetime(2016, 7, 14, 13, 50, 4, 0, tzinfo = pytz.utc), '2016-07-14 13:50:04+00:00\n...\n'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [dingguo.Distance(1.34, u'km'), u"!distance '1.34 km'\n"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [dingguo.ScalarFigure(1.34, u'μm'), u"!scalar '1.34 μm'\n"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_discount_a(), u"!discount\namount: !sum '1.23 EUR'\nname: discount a\n"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_discount_b(), u"!discount\namount: !sum '20.45 EUR'\nname: discount β\n"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_figure_a(), u'!figure\nunit: km\nvalue: 12.3\n'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_figure_b(), u'!figure\nunit: 米\nvalue: 12300\n'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_item_a(), u"!item\nname: item a\nprice_brutto: !sum '1.23 EUR'\n"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_item_b(), u"!item\nname: item β\nprice_brutto: !sum '20.45 EUR'\n"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_person_a(), u'!person\nfirst_name: Fabian Peter\nlast_name: Hammerle\n'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_person_b(), u'!person\nfirst_name: 名字\nlast_name: 贵姓\n'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_sum_a(), u"!sum '1.23 EUR'\n"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_sum_b(), u"!sum '20.45 EUR'\n"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_order_a(), u"""!order 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 customer_id: customer 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 discounts: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 - !discount 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -240,7 +183,122 @@ items: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 order_date: 2016-05-08 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 order_id: id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 platform: platformπ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-""" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+"""], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_article(), u"""!article 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+authors: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+- a 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+- b 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+delivery_date: null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+depth: !scalar '12.3 dm' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+features: supergeil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+height: !scalar '123.0 cm' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+maximum_load: !scalar '40.0 kg' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+name: article name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+price_brutto: !sum '1.23 EUR' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+product_id: 0815 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+quantity: 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+reseller: seller 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+shipper: shipper 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+state: goood 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+width: !scalar '1.23 m' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+"""], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_transportation(), u"""!transportation 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+departure_point: home 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+destination_point: city 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+distance: !distance '3.21 km' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+name: ticket 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+passenger: !person 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  first_name: Fabian Peter 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  last_name: Hammerle 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+price_brutto: !sum '1.23 EUR' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+valid_from: 2016-07-14 13:50:04+01:05 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+"""], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_taxi_ride(), u"""!taxi-ride 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+arrival_time: 2016-05-02 18:10:00+01:05 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+departure_point: home 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+departure_time: 2016-05-02 18:25:00+01:05 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+destination_point: city 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+distance: !distance '3.21 km' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+driver: driver 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+name: taxi ride 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+price_brutto: !sum '1.23 EUR' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+"""], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_order_registry(), u"""!order-registry 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+platformπ: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  id: !order 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    customer_id: customer 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    discounts: [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    items: [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    order_date: 2016-05-08 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    order_id: id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    platform: platformπ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  order_b: !order 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    customer_id: null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    discounts: [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    items: [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    order_date: 2015-05-08 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    order_id: order_b 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    platform: platformπ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+γάμμα: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  order_βήτα: !order 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    customer_id: ρώ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    discounts: [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    items: [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    order_date: 2014-05-08 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    order_id: order_βήτα 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    platform: γάμμα 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+"""], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+def test_to_yaml(source_object, expected_yaml): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    assert to_yaml(source_object) == expected_yaml 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@pytest.mark.parametrize('expected_object,source_yaml', [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [datetime.datetime(2016, 7, 14, 13, 50, 4, 0), '2016-07-14 13:50:04'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [datetime.datetime(2016, 7, 14, 13, 50, 4, 0, tzinfo = pytz.timezone('Europe/Vienna')), '2016-07-14 13:50:04+01:05'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [datetime.datetime(2016, 7, 14, 13, 50, 4, 0, tzinfo = pytz.utc), '2016-07-14 13:50:04+00:00'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [dingguo.Distance(1.34, u'km'), u"!distance '1.34 km'\n"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [dingguo.ScalarFigure(1.34, u'μm'), u"!scalar '1.34 μm'"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_discount_a(), u"!discount\nname: discount a\namount: !sum '1.23 EUR'\n"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_discount_b(), u"!discount\nname: discount β\namount: !sum '20.45 EUR'\n"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_figure_a(), '!figure\nunit: km\nvalue: 12.3\n'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_figure_a(), u'!figure\nunit: km\nvalue: 12.3\n'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_figure_b(), '!figure\nunit: 米\nvalue: 12300\n'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_figure_b(), u'!figure\nunit: 米\nvalue: 12300\n'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_item_a(), u"!item\nname: item a\nprice_brutto: !sum '1.23 EUR'\n"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_item_a(), u"!item\nname: item a\nprice_brutto: !sum 1.23 EUR"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_item_a(), u"!item\nname: item a\nprice_brutto: !sum 1.23 €\n"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_item_b(), u"!item\nname: item β\nprice_brutto: !sum '20.45 EUR'\n"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_person_a(), '!person\nfirst_name: Fabian Peter\nlast_name: Hammerle\n'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_person_a(), u'!person\nfirst_name: Fabian Peter\nlast_name: Hammerle\n'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_person_b(), u'!person\nfirst_name: 名字\nlast_name: 贵姓\n'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_sum_a(), "!sum 1.23 €"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_sum_a(), u"!sum '1.23 EUR'"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_sum_a(), u"!sum '1.23 EUR'"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_sum_a(), u"!sum 1.23 EUR"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_sum_a(), u"!sum 1.23 €"], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [[get_person_a(), get_person_b()], u""" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+- !person 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  first_name: Fabian Peter 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  last_name: Hammerle 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+- !person 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  first_name: 名字 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  last_name: 贵姓"""], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    [get_transportation(), u"""!transportation 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+departure_point: home 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+destination_point: city 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+distance: !distance '3.21 km' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+name: ticket 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+price_brutto: !sum '1.23 EUR' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+route_map: null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+passenger: !person 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  first_name: Fabian Peter 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  last_name: Hammerle 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+valid_from: 2016-07-14 13:50:04+01:05 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+"""], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+def test_from_yaml(expected_object, source_yaml): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    loaded_object = yaml.load(source_yaml) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    assert loaded_object == expected_object 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 def test_order_from_yaml(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     order_loaded = yaml.load(u"""!order 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -266,38 +324,6 @@ platform: platformπ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     order_expected = get_order_a() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     assert order_expected == order_loaded, yaml_diff(order_expected, order_loaded) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def test_scalar_figure_to_yaml(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    assert to_yaml(dingguo.ScalarFigure(1.34, u'μm')) == u"!scalar '1.34 μm'\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def test_scalar_figure_from_yaml(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    assert dingguo.ScalarFigure(1.34, u'μm') == yaml.load(u"!scalar '1.34 μm'") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def test_distance_to_yaml(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    assert to_yaml(dingguo.Distance(1.34, u'km')) == u"!distance '1.34 km'\n" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def test_distance_from_yaml(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    assert dingguo.Distance(1.34, u'km') == yaml.load(u"!distance '1.34 km'\n") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def test_article_to_yaml(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    assert to_yaml(get_article()) == u"""!article 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-authors: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-- a 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-- b 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-delivery_date: null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-depth: !scalar '12.3 dm' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-features: supergeil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-height: !scalar '123.0 cm' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-maximum_load: !scalar '40.0 kg' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-name: article name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-price_brutto: !sum '1.23 EUR' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-product_id: 0815 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-quantity: 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-reseller: seller 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-shipper: shipper 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-state: goood 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-width: !scalar '1.23 m' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-""" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 def test_article_from_yaml(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     assert get_article() == yaml.load(u"""!article 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 authors: 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -318,44 +344,11 @@ maximum_load: !scalar 40.0 kg 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 width: !scalar 1.23 m 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 """) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def test_transportation_to_yaml(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    assert to_yaml(get_transportation()) == u"""!transportation 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-departure_point: home 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-destination_point: city 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-distance: !distance '3.21 km' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-name: ticket 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-price_brutto: !sum '1.23 EUR' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-route_map: null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-""" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def test_transportation_from_yaml(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    assert get_transportation() == yaml.load(u"""!transportation 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-departure_point: home 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-destination_point: city 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-distance: !distance '3.21 km' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-name: ticket 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-price_brutto: !sum '1.23 EUR' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-route_map: null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-""") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def test_taxi_ride_to_yaml(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    assert to_yaml(get_taxi_ride()) == u"""!taxi-ride 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-arrival_time: 2016-05-02 18:10:00 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-departure_point: home 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-departure_time: 2016-05-02 18:25:00 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-destination_point: city 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-distance: !distance '3.21 km' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-driver: driver 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-name: taxi ride 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-price_brutto: !sum '1.23 EUR' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-route_map: null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-""" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 def test_taxi_ride_from_yaml(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     assert get_taxi_ride() == yaml.load(u"""!taxi-ride 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-arrival_time: 2016-05-02 18:10:00 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+arrival_time: 2016-05-02 18:10:00+01:05 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 departure_point: home 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-departure_time: 2016-05-02 18:25:00 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+departure_time: 2016-05-02 18:25:00+01:05 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 destination_point: city 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 distance: !distance '3.21 km' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 driver: driver 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -364,33 +357,6 @@ price_brutto: !sum '1.23 EUR' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 route_map: null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 """) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def test_order_registry_to_yaml(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    assert to_yaml(get_order_registry()) == u"""!order-registry 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-platformπ: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  id: !order 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    customer_id: customer 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    discounts: [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    items: [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    order_date: 2016-05-08 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    order_id: id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    platform: platformπ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  order_b: !order 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    customer_id: null 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    discounts: [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    items: [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    order_date: 2015-05-08 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    order_id: order_b 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    platform: platformπ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-γάμμα: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  order_βήτα: !order 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    customer_id: ρώ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    discounts: [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    items: [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    order_date: 2014-05-08 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    order_id: order_βήτα 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    platform: γάμμα 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-""" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 def test_order_registry_from_yaml(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     expected = get_order_registry() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     loaded = yaml.load(u"""!order-registry 
			 |