test.py 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. #! /usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # Above the run-comment and file encoding comment.
  4. # Comments.
  5. # TODO FIXME XXX
  6. # Keywords.
  7. with break continue del exec return pass print raise global assert lambda yield
  8. for while if elif else import from as try except finally and in is not or
  9. yield from
  10. def functionname
  11. class Classname
  12. def функция
  13. class Класс
  14. await
  15. async def Test
  16. async with
  17. async for
  18. # Type annotations
  19. def myfunc(a: str, something_other,
  20. b: Callable[[str, str], int]) -> Any:
  21. myval: float
  22. mygood: Optional[int, Any] = b('wow', 'oops')
  23. mykey = a
  24. wow = {
  25. mykey: this_should_not_be_type_anno[Any],
  26. 'b': some_data,
  27. }
  28. call_with_dict(a={
  29. 'a': asdf,
  30. 'b': 'zxcb',
  31. mykey: this_should_not_be_type_anno[Any],
  32. }, b=mydata['a'])
  33. # Builtin objects.
  34. True False Ellipsis None NotImplemented
  35. # Builtin function and types.
  36. __import__() abs() all() any() apply() basestring() bool() buffer() callable() chr() classmethod()
  37. cmp() coerce() compile() complex() delattr() dict() dir() divmod() enumerate() eval() execfile() file()
  38. filter() float() frozenset() getattr() globals() hasattr() hash() help() hex() id() input() int()
  39. intern() isinstance() issubclass() iter() len() list() locals() long() map() max() min() object() oct()
  40. open() ord() pow() property() range() raw_input() reduce() reload() repr() reversed() round() set()
  41. setattr() slice() sorted() staticmethod() str() sum() super() tuple() type() unichr() unicode() vars()
  42. xrange() zip()
  43. when_we_dont_call = a.float
  44. float = when_we_dont_call
  45. when_we_call = float(x)
  46. when_we_call = min(a, b)
  47. # Builtin exceptions and warnings.
  48. BaseException Exception StandardError ArithmeticError LookupError
  49. EnvironmentError
  50. AssertionError AttributeError EOFError FloatingPointError GeneratorExit IOError
  51. ImportError IndexError KeyError KeyboardInterrupt MemoryError NameError
  52. NotImplementedError OSError OverflowError ReferenceError RuntimeError
  53. StopIteration SyntaxError IndentationError TabError SystemError SystemExit
  54. TypeError UnboundLocalError UnicodeError UnicodeEncodeError UnicodeDecodeError
  55. UnicodeTranslateError ValueError WindowsError ZeroDivisionError
  56. Warning UserWarning DeprecationWarning PendingDepricationWarning SyntaxWarning
  57. RuntimeWarning FutureWarning ImportWarning UnicodeWarning
  58. # Decorators.
  59. @ decoratorname
  60. @ object.__init__(arg1, arg2)
  61. @ декоратор
  62. @ декоратор.décorateur
  63. # Numbers
  64. 0 1 2 9 10 0x1f .3 12.34 0j 124j 34.2E-3 0b10 0o77 1023434 0x0
  65. 1_1 1_1.2_2 1_2j 0x_1f 0x1_f 34_56e-3 34_56e+3_1 0o7_7
  66. # Erroneous numbers
  67. 077 100L 0xfffffffL 0L 08 0xk 0x 0b102 0o78 0o123LaB
  68. 0_ 0_1 0_x1f 0x1f_ 0_b77 0b77_ .2_ 1_j
  69. # Strings
  70. " test " ' test '
  71. """
  72. test
  73. """
  74. '''
  75. test
  76. '''
  77. " \a\b\c\"\'\n\r \x34\077 \08 \xag"
  78. r" \" \' "
  79. "testтест"
  80. b"test"
  81. b"test\r\n\xffff"
  82. b"тестtest"
  83. br"test"
  84. br"\a\b\n\r"
  85. # Formattings
  86. " %f "
  87. b" %f "
  88. "{0.name!r:b} {0[n]} {name!s: } {{test}} {{}} {} {.__len__:s}"
  89. b"{0.name!r:b} {0[n]} {name!s: } {{test}} {{}} {} {.__len__:s}"
  90. "${test} ${test ${test}aname $$$ $test+nope"
  91. b"${test} ${test ${test}aname $$$ $test+nope"
  92. f"{var}...{arr[123]} normal {var['{'] // 0xff} \"xzcb\" 'xzcb' {var['}'] + 1} text"
  93. f"{expr1 if True or False else expr2} wow {','.join(c.lower() for c in 'asdf')}"
  94. f"hello {expr:.2f} yes {(lambda: 0b1)():#03x} lol {var!r}"
  95. # Doctests.
  96. """
  97. Test:
  98. >>> a = 5
  99. >>> a
  100. 5
  101. Test
  102. """
  103. '''
  104. Test:
  105. >>> a = 5
  106. >>> a
  107. 5
  108. Test
  109. '''
  110. # Erroneous symbols or bad variable names.
  111. $ ? 6xav
  112. && || ===
  113. # Indentation errors.
  114. break
  115. # Trailing space errors.
  116. break
  117. """
  118. test
  119. """