當前位置: 首頁>>代碼示例>>Python>>正文


Python sys.spam方法代碼示例

本文整理匯總了Python中sys.spam方法的典型用法代碼示例。如果您正苦於以下問題:Python sys.spam方法的具體用法?Python sys.spam怎麽用?Python sys.spam使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sys的用法示例。


在下文中一共展示了sys.spam方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_hash

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import spam [as 別名]
def test_hash(self):
        hash(None)
        self.assertEqual(hash(1), hash(1L))
        self.assertEqual(hash(1), hash(1.0))
        hash('spam')
        if have_unicode:
            self.assertEqual(hash('spam'), hash(unicode('spam')))
        hash((0,1,2,3))
        def f(): pass
        self.assertRaises(TypeError, hash, [])
        self.assertRaises(TypeError, hash, {})
        # Bug 1536021: Allow hash to return long objects
        class X:
            def __hash__(self):
                return 2**100
        self.assertEqual(type(hash(X())), int)
        class Y(object):
            def __hash__(self):
                return 2**100
        self.assertEqual(type(hash(Y())), int)
        class Z(long):
            def __hash__(self):
                return self
        self.assertEqual(hash(Z(42)), hash(42L)) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:26,代碼來源:test_builtin.py

示例2: test_hash

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import spam [as 別名]
def test_hash(self):
        hash(None)
        self.assertEqual(hash(1), hash(1))
        self.assertEqual(hash(1), hash(1.0))
        hash('spam')
        if True:      # Was: if have_unicode:
            self.assertEqual(hash('spam'), hash(unicode('spam')))
        hash((0,1,2,3))
        def f(): pass
        self.assertRaises(TypeError, hash, [])
        self.assertRaises(TypeError, hash, {})
        # Bug 1536021: Allow hash to return long objects
        class X:
            def __hash__(self):
                return 2**100
        self.assertEqual(type(hash(X())), int)
        class Y(object):
            def __hash__(self):
                return 2**100
        self.assertEqual(type(hash(Y())), int)
        class Z(long):
            def __hash__(self):
                return self
        self.assertEqual(hash(Z(42)), hash(42)) 
開發者ID:hughperkins,項目名稱:kgsgo-dataset-preprocessor,代碼行數:26,代碼來源:test_builtins.py

示例3: test_hash

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import spam [as 別名]
def test_hash(self):
        hash(None)
        self.assertEqual(hash(1), hash(1))
        self.assertEqual(hash(1), hash(1.0))
        hash('spam')
        self.assertEqual(hash('spam'), hash(b'spam'))
        hash((0,1,2,3))
        def f(): pass
        self.assertRaises(TypeError, hash, [])
        self.assertRaises(TypeError, hash, {})
        # Bug 1536021: Allow hash to return long objects
        class X:
            def __hash__(self):
                return 2**100
        self.assertEqual(type(hash(X())), int)
        class Z(int):
            def __hash__(self):
                return self
        self.assertEqual(hash(Z(42)), hash(42)) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:21,代碼來源:test_builtin.py

示例4: test_hash

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import spam [as 別名]
def test_hash(self):
        hash(None)
        self.assertEqual(hash(1), hash(1L))
        self.assertEqual(hash(1), hash(1.0))
        hash('spam')
        if have_unicode:
            self.assertEqual(hash('spam'), hash(unicode('spam')))
        hash((0,1,2,3))
        def f(): pass
        self.assertRaises(TypeError, hash, [])
        self.assertRaises(TypeError, hash, {})
        # Bug 1536021: Allow hash to return long objects
        class X:
            def __hash__(self):
                return 2**100
        self.assertEquals(type(hash(X())), int)
        class Y(object):
            def __hash__(self):
                return 2**100
        self.assertEquals(type(hash(Y())), int)
        class Z(long):
            def __hash__(self):
                return self
        self.assertEquals(hash(Z(42)), hash(42L)) 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:26,代碼來源:test_builtin.py

示例5: test_delattr

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import spam [as 別名]
def test_delattr(self):
        import sys
        sys.spam = 1
        delattr(sys, 'spam')
        self.assertRaises(TypeError, delattr) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:7,代碼來源:test_builtin.py

示例6: test_id

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import spam [as 別名]
def test_id(self):
        id(None)
        id(1)
        id(1L)
        id(1.0)
        id('spam')
        id((0,1,2,3))
        id([0,1,2,3])
        id({'spam': 1, 'eggs': 2, 'ham': 3})

    # Test input() later, together with raw_input

    # test_int(): see test_int.py for int() tests. 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:15,代碼來源:test_builtin.py

示例7: test_setattr

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import spam [as 別名]
def test_setattr(self):
        setattr(sys, 'spam', 1)
        self.assertEqual(sys.spam, 1)
        self.assertRaises(TypeError, setattr, sys, 1, 'spam')
        self.assertRaises(TypeError, setattr) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:7,代碼來源:test_builtin.py

示例8: test_new_type

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import spam [as 別名]
def test_new_type(self):
        A = type('A', (), {})
        self.assertEqual(A.__name__, 'A')
        self.assertEqual(A.__module__, __name__)
        self.assertEqual(A.__bases__, (object,))
        self.assertIs(A.__base__, object)
        x = A()
        self.assertIs(type(x), A)
        self.assertIs(x.__class__, A)

        class B:
            def ham(self):
                return 'ham%d' % self
        C = type('C', (B, int), {'spam': lambda self: 'spam%s' % self})
        self.assertEqual(C.__name__, 'C')
        self.assertEqual(C.__module__, __name__)
        self.assertEqual(C.__bases__, (B, int))
        self.assertIs(C.__base__, int)
        self.assertIn('spam', C.__dict__)
        self.assertNotIn('ham', C.__dict__)
        x = C(42)
        self.assertEqual(x, 42)
        self.assertIs(type(x), C)
        self.assertIs(x.__class__, C)
        self.assertEqual(x.ham(), 'ham42')
        self.assertEqual(x.spam(), 'spam42')
        self.assertEqual(x.bit_length(), 6) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:29,代碼來源:test_builtin.py

示例9: test_id

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import spam [as 別名]
def test_id(self):
        id(None)
        id(1)
        id(1)
        id(1.0)
        id('spam')
        id((0,1,2,3))
        id([0,1,2,3])
        id({'spam': 1, 'eggs': 2, 'ham': 3})

    # Test input() later, together with raw_input

    # test_int(): see test_int.py for int() tests. 
開發者ID:hughperkins,項目名稱:kgsgo-dataset-preprocessor,代碼行數:15,代碼來源:test_builtins.py

示例10: test_delattr

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import spam [as 別名]
def test_delattr(self):
        sys.spam = 1
        delattr(sys, 'spam')
        self.assertRaises(TypeError, delattr) 
開發者ID:hughperkins,項目名稱:kgsgo-dataset-preprocessor,代碼行數:6,代碼來源:test_builtins.py

示例11: test_id

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import spam [as 別名]
def test_id(self):
        id(None)
        id(1)
        id(1.0)
        id('spam')
        id((0,1,2,3))
        id([0,1,2,3])
        id({'spam': 1, 'eggs': 2, 'ham': 3})

    # Test input() later, alphabetized as if it were raw_input 
開發者ID:hughperkins,項目名稱:kgsgo-dataset-preprocessor,代碼行數:12,代碼來源:test_builtins.py

示例12: test_setattr

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import spam [as 別名]
def test_setattr(self):
        setattr(sys, 'spam', 1)
        self.assertEqual(sys.spam, 1)
        self.assertRaises(TypeError, setattr, sys, 1, 'spam')
        self.assertRaises(TypeError, setattr)

    # test_str(): see test_unicode.py and test_bytes.py for str() tests. 
開發者ID:hughperkins,項目名稱:kgsgo-dataset-preprocessor,代碼行數:9,代碼來源:test_builtins.py


注:本文中的sys.spam方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。