Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/pygments/lexers/testing.py: 95%
21 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-07-01 06:54 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-07-01 06:54 +0000
1"""
2 pygments.lexers.testing
3 ~~~~~~~~~~~~~~~~~~~~~~~
5 Lexers for testing languages.
7 :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
8 :license: BSD, see LICENSE for details.
9"""
11from pygments.lexer import RegexLexer, include, bygroups
12from pygments.token import Comment, Keyword, Name, String, Number, Generic, Text
14__all__ = ['GherkinLexer', 'TAPLexer']
17class GherkinLexer(RegexLexer):
18 """
19 For Gherkin syntax.
21 .. versionadded:: 1.2
22 """
23 name = 'Gherkin'
24 aliases = ['gherkin', 'cucumber']
25 filenames = ['*.feature']
26 mimetypes = ['text/x-gherkin']
28 feature_keywords = '^(기능|機能|功能|フィーチャ|خاصية|תכונה|Функціонал|Функционалност|Функционал|Фича|Особина|Могућност|Özellik|Właściwość|Tính năng|Trajto|Savybė|Požiadavka|Požadavek|Osobina|Ominaisuus|Omadus|OH HAI|Mogućnost|Mogucnost|Jellemző|Fīča|Funzionalità|Funktionalität|Funkcionalnost|Funkcionalitāte|Funcționalitate|Functionaliteit|Functionalitate|Funcionalitat|Funcionalidade|Fonctionnalité|Fitur|Feature|Egenskap|Egenskab|Crikey|Característica|Arwedd)(:)(.*)$'
29 feature_element_keywords = '^(\\s*)(시나리오 개요|시나리오|배경|背景|場景大綱|場景|场景大纲|场景|劇本大綱|劇本|剧本大纲|剧本|テンプレ|シナリオテンプレート|シナリオテンプレ|シナリオアウトライン|シナリオ|سيناريو مخطط|سيناريو|الخلفية|תרחיש|תבנית תרחיש|רקע|Тарих|Сценарій|Сценарио|Сценарий структураси|Сценарий|Структура сценарію|Структура сценарија|Структура сценария|Скица|Рамка на сценарий|Пример|Предыстория|Предистория|Позадина|Передумова|Основа|Концепт|Контекст|Założenia|Wharrimean is|Tình huống|The thing of it is|Tausta|Taust|Tapausaihio|Tapaus|Szenariogrundriss|Szenario|Szablon scenariusza|Stsenaarium|Struktura scenarija|Skica|Skenario konsep|Skenario|Situācija|Senaryo taslağı|Senaryo|Scénář|Scénario|Schema dello scenario|Scenārijs pēc parauga|Scenārijs|Scenár|Scenaro|Scenariusz|Scenariul de şablon|Scenariul de sablon|Scenariu|Scenario Outline|Scenario Amlinellol|Scenario|Scenarijus|Scenarijaus šablonas|Scenarij|Scenarie|Rerefons|Raamstsenaarium|Primer|Pozadí|Pozadina|Pozadie|Plan du scénario|Plan du Scénario|Osnova scénáře|Osnova|Náčrt Scénáře|Náčrt Scenáru|Mate|MISHUN SRSLY|MISHUN|Kịch bản|Konturo de la scenaro|Kontext|Konteksts|Kontekstas|Kontekst|Koncept|Khung tình huống|Khung kịch bản|Háttér|Grundlage|Geçmiş|Forgatókönyv vázlat|Forgatókönyv|Fono|Esquema do Cenário|Esquema do Cenario|Esquema del escenario|Esquema de l\'escenari|Escenario|Escenari|Dis is what went down|Dasar|Contexto|Contexte|Contesto|Condiţii|Conditii|Cenário|Cenario|Cefndir|Bối cảnh|Blokes|Bakgrunn|Bakgrund|Baggrund|Background|B4|Antecedents|Antecedentes|All y\'all|Achtergrond|Abstrakt Scenario|Abstract Scenario)(:)(.*)$'
30 examples_keywords = '^(\\s*)(예|例子|例|サンプル|امثلة|דוגמאות|Сценарији|Примери|Приклади|Мисоллар|Значения|Örnekler|Voorbeelden|Variantai|Tapaukset|Scenarios|Scenariji|Scenarijai|Příklady|Példák|Príklady|Przykłady|Primjeri|Primeri|Piemēri|Pavyzdžiai|Paraugs|Juhtumid|Exemplos|Exemples|Exemplele|Exempel|Examples|Esempi|Enghreifftiau|Ekzemploj|Eksempler|Ejemplos|EXAMPLZ|Dữ liệu|Contoh|Cobber|Beispiele)(:)(.*)$'
31 step_keywords = '^(\\s*)(하지만|조건|먼저|만일|만약|단|그리고|그러면|那麼|那么|而且|當|当|前提|假設|假设|假如|假定|但是|但し|並且|并且|同時|同时|もし|ならば|ただし|しかし|かつ|و |متى |لكن |عندما |ثم |بفرض |اذاً |כאשר |וגם |בהינתן |אזי |אז |אבל |Якщо |Унда |То |Припустимо, що |Припустимо |Онда |Но |Нехай |Лекин |Когато |Када |Кад |К тому же |И |Задато |Задати |Задате |Если |Допустим |Дадено |Ва |Бирок |Аммо |Али |Але |Агар |А |І |Și |És |Zatati |Zakładając |Zadato |Zadate |Zadano |Zadani |Zadan |Youse know when youse got |Youse know like when |Yna |Ya know how |Ya gotta |Y |Wun |Wtedy |When y\'all |When |Wenn |WEN |Và |Ve |Und |Un |Thì |Then y\'all |Then |Tapi |Tak |Tada |Tad |Så |Stel |Soit |Siis |Si |Sed |Se |Quando |Quand |Quan |Pryd |Pokud |Pokiaľ |Però |Pero |Pak |Oraz |Onda |Ond |Oletetaan |Og |Och |O zaman |Når |När |Niin |Nhưng |N |Mutta |Men |Mas |Maka |Majd |Mais |Maar |Ma |Lorsque |Lorsqu\'|Kun |Kuid |Kui |Khi |Keď |Ketika |Když |Kaj |Kai |Kada |Kad |Jeżeli |Ja |Ir |I CAN HAZ |I |Ha |Givun |Givet |Given y\'all |Given |Gitt |Gegeven |Gegeben sei |Fakat |Eğer ki |Etant donné |Et |Então |Entonces |Entao |En |Eeldades |E |Duota |Dun |Donitaĵo |Donat |Donada |Do |Diyelim ki |Dengan |Den youse gotta |De |Dato |Dar |Dann |Dan |Dado |Dacă |Daca |DEN |Când |Cuando |Cho |Cept |Cand |Cal |But y\'all |But |Buh |Biết |Bet |BUT |Atès |Atunci |Atesa |Anrhegedig a |Angenommen |And y\'all |And |An |Ama |Als |Alors |Allora |Ali |Aleshores |Ale |Akkor |Aber |AN |A také |A |\\* )'
33 tokens = {
34 'comments': [
35 (r'^\s*#.*$', Comment),
36 ],
37 'feature_elements': [
38 (step_keywords, Keyword, "step_content_stack"),
39 include('comments'),
40 (r"(\s|.)", Name.Function),
41 ],
42 'feature_elements_on_stack': [
43 (step_keywords, Keyword, "#pop:2"),
44 include('comments'),
45 (r"(\s|.)", Name.Function),
46 ],
47 'examples_table': [
48 (r"\s+\|", Keyword, 'examples_table_header'),
49 include('comments'),
50 (r"(\s|.)", Name.Function),
51 ],
52 'examples_table_header': [
53 (r"\s+\|\s*$", Keyword, "#pop:2"),
54 include('comments'),
55 (r"\\\|", Name.Variable),
56 (r"\s*\|", Keyword),
57 (r"[^|]", Name.Variable),
58 ],
59 'scenario_sections_on_stack': [
60 (feature_element_keywords,
61 bygroups(Name.Function, Keyword, Keyword, Name.Function),
62 "feature_elements_on_stack"),
63 ],
64 'narrative': [
65 include('scenario_sections_on_stack'),
66 include('comments'),
67 (r"(\s|.)", Name.Function),
68 ],
69 'table_vars': [
70 (r'(<[^>]+>)', Name.Variable),
71 ],
72 'numbers': [
73 (r'(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', String),
74 ],
75 'string': [
76 include('table_vars'),
77 (r'(\s|.)', String),
78 ],
79 'py_string': [
80 (r'"""', Keyword, "#pop"),
81 include('string'),
82 ],
83 'step_content_root': [
84 (r"$", Keyword, "#pop"),
85 include('step_content'),
86 ],
87 'step_content_stack': [
88 (r"$", Keyword, "#pop:2"),
89 include('step_content'),
90 ],
91 'step_content': [
92 (r'"', Name.Function, "double_string"),
93 include('table_vars'),
94 include('numbers'),
95 include('comments'),
96 (r'(\s|.)', Name.Function),
97 ],
98 'table_content': [
99 (r"\s+\|\s*$", Keyword, "#pop"),
100 include('comments'),
101 (r"\\\|", String),
102 (r"\s*\|", Keyword),
103 include('string'),
104 ],
105 'double_string': [
106 (r'"', Name.Function, "#pop"),
107 include('string'),
108 ],
109 'root': [
110 (r'\n', Name.Function),
111 include('comments'),
112 (r'"""', Keyword, "py_string"),
113 (r'\s+\|', Keyword, 'table_content'),
114 (r'"', Name.Function, "double_string"),
115 include('table_vars'),
116 include('numbers'),
117 (r'(\s*)(@[^@\r\n\t ]+)', bygroups(Name.Function, Name.Tag)),
118 (step_keywords, bygroups(Name.Function, Keyword),
119 'step_content_root'),
120 (feature_keywords, bygroups(Keyword, Keyword, Name.Function),
121 'narrative'),
122 (feature_element_keywords,
123 bygroups(Name.Function, Keyword, Keyword, Name.Function),
124 'feature_elements'),
125 (examples_keywords,
126 bygroups(Name.Function, Keyword, Keyword, Name.Function),
127 'examples_table'),
128 (r'(\s|.)', Name.Function),
129 ]
130 }
132 def analyse_text(self, text):
133 return
136class TAPLexer(RegexLexer):
137 """
138 For Test Anything Protocol (TAP) output.
140 .. versionadded:: 2.1
141 """
142 name = 'TAP'
143 url = 'https://testanything.org/'
144 aliases = ['tap']
145 filenames = ['*.tap']
147 tokens = {
148 'root': [
149 # A TAP version may be specified.
150 (r'^TAP version \d+\n', Name.Namespace),
152 # Specify a plan with a plan line.
153 (r'^1\.\.\d+', Keyword.Declaration, 'plan'),
155 # A test failure
156 (r'^(not ok)([^\S\n]*)(\d*)',
157 bygroups(Generic.Error, Text, Number.Integer), 'test'),
159 # A test success
160 (r'^(ok)([^\S\n]*)(\d*)',
161 bygroups(Keyword.Reserved, Text, Number.Integer), 'test'),
163 # Diagnostics start with a hash.
164 (r'^#.*\n', Comment),
166 # TAP's version of an abort statement.
167 (r'^Bail out!.*\n', Generic.Error),
169 # TAP ignores any unrecognized lines.
170 (r'^.*\n', Text),
171 ],
172 'plan': [
173 # Consume whitespace (but not newline).
174 (r'[^\S\n]+', Text),
176 # A plan may have a directive with it.
177 (r'#', Comment, 'directive'),
179 # Or it could just end.
180 (r'\n', Comment, '#pop'),
182 # Anything else is wrong.
183 (r'.*\n', Generic.Error, '#pop'),
184 ],
185 'test': [
186 # Consume whitespace (but not newline).
187 (r'[^\S\n]+', Text),
189 # A test may have a directive with it.
190 (r'#', Comment, 'directive'),
192 (r'\S+', Text),
194 (r'\n', Text, '#pop'),
195 ],
196 'directive': [
197 # Consume whitespace (but not newline).
198 (r'[^\S\n]+', Comment),
200 # Extract todo items.
201 (r'(?i)\bTODO\b', Comment.Preproc),
203 # Extract skip items.
204 (r'(?i)\bSKIP\S*', Comment.Preproc),
206 (r'\S+', Comment),
208 (r'\n', Comment, '#pop:2'),
209 ],
210 }