beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From al...@apache.org
Subject [1/2] beam git commit: add unicode type to the typeDict attribute in Python SDK
Date Fri, 10 Mar 2017 19:56:51 GMT
Repository: beam
Updated Branches:
  refs/heads/master 818fc9412 -> 54390a333


add unicode type to the typeDict attribute in Python SDK


Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/7daf9abd
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/7daf9abd
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/7daf9abd

Branch: refs/heads/master
Commit: 7daf9abd52d4b89c563d370396506d2db71b7700
Parents: 818fc94
Author: tajima <tajima@tajima-taso.jp>
Authored: Thu Mar 9 18:08:25 2017 +0900
Committer: Ahmet Altay <altay@google.com>
Committed: Fri Mar 10 11:56:06 2017 -0800

----------------------------------------------------------------------
 sdks/python/apache_beam/transforms/display.py      |  1 +
 sdks/python/apache_beam/transforms/display_test.py | 11 +++++++++++
 2 files changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/7daf9abd/sdks/python/apache_beam/transforms/display.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/transforms/display.py b/sdks/python/apache_beam/transforms/display.py
index 5e25060..2ced1af 100644
--- a/sdks/python/apache_beam/transforms/display.py
+++ b/sdks/python/apache_beam/transforms/display.py
@@ -160,6 +160,7 @@ class DisplayDataItem(object):
   display item belongs to.
   """
   typeDict = {str:'STRING',
+              unicode:'STRING',
               int:'INTEGER',
               float:'FLOAT',
               bool: 'BOOLEAN',

http://git-wip-us.apache.org/repos/asf/beam/blob/7daf9abd/sdks/python/apache_beam/transforms/display_test.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/transforms/display_test.py b/sdks/python/apache_beam/transforms/display_test.py
index 5a95c42..5e106e5 100644
--- a/sdks/python/apache_beam/transforms/display_test.py
+++ b/sdks/python/apache_beam/transforms/display_test.py
@@ -122,6 +122,17 @@ class DisplayDataTest(unittest.TestCase):
         DisplayDataItemMatcher('extra_packages',
                                str(['package1', 'package2']))))
 
+  def test_unicode_type_display_data(self):
+    class MyDoFn(beam.DoFn):
+      def display_data(self):
+        return {'unicode_string': unicode('my string'),
+                'unicode_literal_string': u'my literal string'}
+
+    fn = MyDoFn()
+    dd = DisplayData.create_from(fn)
+    for item in dd.items:
+      self.assertEqual(item.type, 'STRING')
+
   def test_base_cases(self):
     """ Tests basic display data cases (key:value, key:dict)
     It does not test subcomponent inclusion


Mime
View raw message