当前位置: 首页>>代码示例>>Python>>正文


Python Space.get方法代码示例

本文整理汇总了Python中space.Space.get方法的典型用法代码示例。如果您正苦于以下问题:Python Space.get方法的具体用法?Python Space.get怎么用?Python Space.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在space.Space的用法示例。


在下文中一共展示了Space.get方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testDeepCopy

# 需要导入模块: from space import Space [as 别名]
# 或者: from space.Space import get [as 别名]
 def testDeepCopy(self):
     space1 = Space('hello world')
     space2 = space1.clone()
     self.assertEqual(space2.get('hello'), 'world', 'Clone should work')
     space2.set('hello', 'mom')
     self.assertEqual(space1.get('hello'), 'world', 'Clone makes deep copy')
     space3 = space1
     space3.set('hello', 'dad')
     self.assertEqual(space1.get('hello'), 'dad', '= makes shallow copy')
     space1.set('anotherSpace', Space('123 456'))
     self.assertEqual(space3.get('anotherSpace 123'), '456')
开发者ID:breck7,项目名称:spacepython,代码行数:13,代码来源:test_space.py

示例2: test_multiline

# 需要导入模块: from space import Space [as 别名]
# 或者: from space.Space import get [as 别名]
    def test_multiline(self):
        space = Space('my multiline\n string')
        self.assertEqual(space.get('my'), 'multiline\nstring')
        
        space2 = Space('my \n \n multiline\n string')
        self.assertEqual(space2.get('my'), '\n\nmultiline\nstring')

        space3 = Space('brave new\n world')
        self.assertEqual(space3.get('brave'), 'new\nworld', 'ml value correct')
        self.assertEqual(str(space3), 'brave new\n world\n', 'multiline does not begin with nl')

        space4 = Space('brave \n new\n world')
        self.assertEqual(space4.get('brave'), '\nnew\nworld', 'ml begin with nl value correct')
开发者ID:jyxt,项目名称:spacepython,代码行数:15,代码来源:test_space.py

示例3: test_append

# 需要导入模块: from space import Space [as 别名]
# 或者: from space.Space import get [as 别名]
 def test_append(self):
     space = Space('hello world')
     space.append('foo', 'bar')
     space.set('foo2', 'bar')
     space.append('foo', 'two')
     self.assertEqual(space.get('foo'), 'bar')
     self.assertEqual(space.length(), 4)
开发者ID:jyxt,项目名称:spacepython,代码行数:9,代码来源:test_space.py

示例4: test_set

# 需要导入模块: from space import Space [as 别名]
# 或者: from space.Space import get [as 别名]
 def test_set(self):
     space = Space('hello world')
     self.assertEqual(space.get('hello'), 'world')
     self.assertTrue(isinstance(space.set('hello', 'mom'), Space), 'set returns self for chaining')
     
     intSpace = Space()
     intSpace.set(2, 'hi')
     self.assertEqual(intSpace.get(2), 'hi')
     
     emptyStringSpace = Space()
     emptyStringSpace.set('boom', '')
     self.assertEqual(emptyStringSpace.get('boom'), '')
     
     # this is important, value should have been changed
     self.assertEqual(space.get('hello'), 'mom')
     space.set('head style color', 'blue')
     self.assertEqual(space.get('head style color'), 'blue')
开发者ID:jyxt,项目名称:spacepython,代码行数:19,代码来源:test_space.py

示例5: testMultiLine

# 需要导入模块: from space import Space [as 别名]
# 或者: from space.Space import get [as 别名]
    def testMultiLine(self):
        string = 'user\n\
name Aristotle\n\
admin false\n\
stage\n\
name home\n\
domain test.test.com\n\
pro false\n\
domains\n\
 test.test.com\n\
  images\n\
  blocks\n\
  users\n\
  stage home\n\
  pages\n\
   home\n\
    settings\n\
     data\n\
      title Hello, World\n\
    block1\n\
     content Hello world\n'

        space = Space(string)
        self.assertEqual(space.get('domains test.test.com pages home settings data title'), 'Hello, World', 'Multiline creation shuold be OK')
开发者ID:breck7,项目名称:spacepython,代码行数:26,代码来源:test_space.py

示例6: testClearWithSpaceArgument

# 需要导入模块: from space import Space [as 别名]
# 或者: from space.Space import get [as 别名]
 def testClearWithSpaceArgument(self):
     space = Space("Hellow world")
     space.clear("hey there")
     self.assertEqual(space.length(), 1)
     self.assertEqual(space.get('hey'), 'there', 'Clear with a Space argument should deep copy the argument Space')
开发者ID:breck7,项目名称:spacepython,代码行数:7,代码来源:test_space.py

示例7: testLength

# 需要导入模块: from space import Space [as 别名]
# 或者: from space.Space import get [as 别名]
 def testLength(self):
     space = Space('list\nsingle value')
     self.assertEqual(space.length(), 2, 'space should have 2 names')  # 'name' here means 'key'
     self.assertTrue(isinstance(space.get('list'), Space), 'name without a trailing space should be name')
开发者ID:breck7,项目名称:spacepython,代码行数:6,代码来源:test_space.py

示例8: testPathNotExist

# 需要导入模块: from space import Space [as 别名]
# 或者: from space.Space import get [as 别名]
 def testPathNotExist(self):
     space = Space('Hello\n one 1\n two 2')
     self.assertEqual(space.get('Hello world one'), None, 'Should return None if path does not exist')
开发者ID:breck7,项目名称:spacepython,代码行数:5,代码来源:test_space.py

示例9: testKeyNotExist

# 需要导入模块: from space import Space [as 别名]
# 或者: from space.Space import get [as 别名]
 def testKeyNotExist(self):
     space = Space('foobar\n leaf 1')
     self.assertEqual(space.get('Hi'), None, 'Should return None if key does not exist')
开发者ID:breck7,项目名称:spacepython,代码行数:5,代码来源:test_space.py

示例10: testNestSpace

# 需要导入模块: from space import Space [as 别名]
# 或者: from space.Space import get [as 别名]
 def testNestSpace(self):
     space = Space('foobar\n one 1')
     self.assertTrue(isinstance(space.get('foobar'), Space), 'Nested space should be Space type')
开发者ID:breck7,项目名称:spacepython,代码行数:5,代码来源:test_space.py

示例11: testGetSet

# 需要导入模块: from space import Space [as 别名]
# 或者: from space.Space import get [as 别名]
 def testGetSet(self):
     space = Space('Hello World')
     self.assertEqual(space.get("Hello"), 'World', 'Property should be accessible')
     self.assertEqual(type(space.get("Hello")), str, 'Leaf should be string')
     space.set('foo', 'bar')
     self.assertEqual(space.get('foo'), 'bar', 'Space should be modifiable' )
开发者ID:breck7,项目名称:spacepython,代码行数:8,代码来源:test_space.py

示例12: testConcat

# 需要导入模块: from space import Space [as 别名]
# 或者: from space.Space import get [as 别名]
 def testConcat(self):
     space1 = Space('hi world')
     b = Space('hello there')
     space1.concat(b)
     self.assertEqual(space1.get('hello'), 'there')
开发者ID:jyxt,项目名称:spacepython,代码行数:7,代码来源:test_space.py


注:本文中的space.Space.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。