aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches/behave-skip-a-couple-of-tests.patch
blob: e3d4e152412f105cfa25cc255c16aa128cf9d2f3 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
Fix build with Python 3.8, this is a patch based on upstream commit [1].

1: c000c88eb5239b87f299c85e83b349b0ef387ae7


diff --git a/behave.ini b/behave.ini
index 45c0f0d7..952240d6 100644
--- a/behave.ini
+++ b/behave.ini
@@ -15,8 +15,9 @@ show_skipped = false
 format   = rerun
     progress3
 outfiles = rerun.txt
-    reports/report_progress3.txt
+    build/behave.reports/report_progress3.txt
 junit = true
+junit_directory = build/behave.reports
 logging_level = INFO
 # logging_format = LOG.%(levelname)-8s  %(name)-10s: %(message)s
 # logging_format = LOG.%(levelname)-8s  %(asctime)s  %(name)-10s: %(message)s
diff --git a/features/environment.py b/features/environment.py
index 4744e89a..3769ee40 100644
--- a/features/environment.py
+++ b/features/environment.py
@@ -1,5 +1,7 @@
 # -*- coding: UTF-8 -*-
+# FILE: features/environemnt.py
 
+from __future__ import absolute_import, print_function
 from behave.tag_matcher import ActiveTagMatcher, setup_active_tag_values
 from behave4cmd0.setup_command_shell import setup_command_shell_processors4behave
 import platform
@@ -20,6 +22,15 @@
 }
 active_tag_matcher = ActiveTagMatcher(active_tag_value_provider)
 
+
+def print_active_tags_summary():
+    active_tag_data = active_tag_value_provider
+    print("ACTIVE-TAG SUMMARY:")
+    print("use.with_python.version=%s" % active_tag_data.get("python.version"))
+    # print("use.with_os=%s" % active_tag_data.get("os"))
+    print()
+
+
 # -----------------------------------------------------------------------------
 # HOOKS:
 # -----------------------------------------------------------------------------
@@ -30,11 +41,14 @@ def before_all(context):
     setup_python_path()
     setup_context_with_global_params_test(context)
     setup_command_shell_processors4behave()
+    print_active_tags_summary()
+
 
 def before_feature(context, feature):
     if active_tag_matcher.should_exclude_with(feature.tags):
         feature.skip(reason=active_tag_matcher.exclude_reason)
 
+
 def before_scenario(context, scenario):
     if active_tag_matcher.should_exclude_with(scenario.effective_tags):
         scenario.skip(reason=active_tag_matcher.exclude_reason)
diff --git a/features/step.duplicated_step.feature b/features/step.duplicated_step.feature
index 59888b0f..396cca27 100644
--- a/features/step.duplicated_step.feature
+++ b/features/step.duplicated_step.feature
@@ -32,11 +32,11 @@ Feature: Duplicated Step Definitions
         AmbiguousStep: @given('I call Alice') has already been defined in
         existing step @given('I call Alice') at features/steps/alice_steps.py:3
         """
-    And the command output should contain:
-        """
-        File "features/steps/alice_steps.py", line 7, in <module>
-        @given(u'I call Alice')
-        """
+    # -- DISABLED: Python 3.8 traceback line numbers differ w/ decorators (+1).
+    # And the command output should contain:
+    #    """
+    #    File "features/steps/alice_steps.py", line 7, in <module>
+    #    """
 
 
   Scenario: Duplicated Step Definition in another File
@@ -70,11 +70,11 @@ Feature: Duplicated Step Definitions
         AmbiguousStep: @given('I call Bob') has already been defined in
         existing step @given('I call Bob') at features/steps/bob1_steps.py:3
         """
-    And the command output should contain:
-        """
-        File "features/steps/bob2_steps.py", line 3, in <module>
-        @given('I call Bob')
-        """
+    # -- DISABLED: Python 3.8 traceback line numbers differ w/ decorators (+1).
+    # And the command output should contain:
+    #    """
+    #    File "features/steps/bob2_steps.py", line 3, in <module>
+    #    """
 
   @xfail
   Scenario: Duplicated Same Step Definition via import from another File
diff --git a/issue.features/environment.py b/issue.features/environment.py
index 2dfec751..7e48ee03 100644
--- a/issue.features/environment.py
+++ b/issue.features/environment.py
@@ -1,5 +1,5 @@
 # -*- coding: UTF-8 -*-
-# FILE: features/environment.py
+# FILE: issue.features/environemnt.py
 # pylint: disable=unused-argument
 """
 Functionality:
@@ -7,17 +7,20 @@
   * active tags
 """
 
-from __future__ import print_function
+
+from __future__ import absolute_import, print_function
 import sys
 import platform
 import os.path
 import six
 from behave.tag_matcher import ActiveTagMatcher
 from behave4cmd0.setup_command_shell import setup_command_shell_processors4behave
-# PREPARED:
-# from behave.tag_matcher import setup_active_tag_values
+# PREPARED: from behave.tag_matcher import setup_active_tag_values
 
 
+# ---------------------------------------------------------------------------
+# TEST SUPPORT: For Active Tags
+# ---------------------------------------------------------------------------
 def require_tool(tool_name):
     """Check if a tool (an executable program) is provided on this platform.
 
@@ -45,12 +48,14 @@ def require_tool(tool_name):
     # print("TOOL-NOT-FOUND: %s" % tool_name)
     return False
 
+
 def as_bool_string(value):
     if bool(value):
         return "yes"
     else:
         return "no"
 
+
 def discover_ci_server():
     # pylint: disable=invalid-name
     ci_server = "none"
@@ -67,11 +72,17 @@ def discover_ci_server():
     return ci_server
 
 
+# ---------------------------------------------------------------------------
+# BEHAVE SUPPORT: Active Tags
+# ---------------------------------------------------------------------------
 # -- MATCHES ANY TAGS: @use.with_{category}={value}
 # NOTE: active_tag_value_provider provides category values for active tags.
+python_version = "%s.%s" % sys.version_info[:2]
 active_tag_value_provider = {
+    "platform": sys.platform,
     "python2": str(six.PY2).lower(),
     "python3": str(six.PY3).lower(),
+    "python.version": python_version,
     # -- python.implementation: cpython, pypy, jython, ironpython
     "python.implementation": platform.python_implementation().lower(),
     "pypy":    str("__pypy__" in sys.modules).lower(),
@@ -82,17 +92,33 @@ def discover_ci_server():
 }
 active_tag_matcher = ActiveTagMatcher(active_tag_value_provider)
 
+
+def print_active_tags_summary():
+    active_tag_data = active_tag_value_provider
+    print("ACTIVE-TAG SUMMARY:")
+    print("use.with_python.version=%s" % active_tag_data.get("python.version"))
+    # print("use.with_platform=%s" % active_tag_data.get("platform"))
+    # print("use.with_os=%s" % active_tag_data.get("os"))
+    print()
+
+
+# ---------------------------------------------------------------------------
+# BEHAVE HOOKS:
+# ---------------------------------------------------------------------------
 def before_all(context):
     # -- SETUP ACTIVE-TAG MATCHER (with userdata):
     # USE: behave -D browser=safari ...
-    # NOT-NEEDED: setup_active_tag_values(active_tag_value_provider,
-    #                                     context.config.userdata)
+    # NOT-NEEDED:
+    # setup_active_tag_values(active_tag_value_provider, context.config.userdata)
     setup_command_shell_processors4behave()
+    print_active_tags_summary()
+
 
 def before_feature(context, feature):
     if active_tag_matcher.should_exclude_with(feature.tags):
         feature.skip(reason=active_tag_matcher.exclude_reason)
 
+
 def before_scenario(context, scenario):
     if active_tag_matcher.should_exclude_with(scenario.effective_tags):
         scenario.skip(reason=active_tag_matcher.exclude_reason)
diff --git a/issue.features/issue0330.feature b/issue.features/issue0330.feature
index dc1ebe75..81cb6e29 100644
--- a/issue.features/issue0330.feature
+++ b/issue.features/issue0330.feature
@@ -70,6 +70,7 @@ Feature: Issue #330: Skipped scenarios are included in junit reports when --no-s
     And note that "bob.feature is skipped"
 
 
+  @not.with_python.version=3.8
   Scenario: Junit report for skipped feature is created with --show-skipped
     When I run "behave --junit -t @tag1 --show-skipped @alice_and_bob.featureset"
     Then it should pass with:
@@ -83,6 +84,23 @@ Feature: Issue #330: Skipped scenarios are included in junit reports when --no-s
       <testsuite errors="0" failures="0" name="bob.Bob" skipped="1" tests="1" time="0.0">
       """
 
+  @use.with_python.version=3.8
+  Scenario: Junit report for skipped feature is created with --show-skipped
+    When I run "behave --junit -t @tag1 --show-skipped @alice_and_bob.featureset"
+    Then it should pass with:
+      """
+      1 feature passed, 0 failed, 1 skipped
+      """
+    And a file named "test_results/TESTS-alice.xml" exists
+    And a file named "test_results/TESTS-bob.xml" exists
+    And the file "test_results/TESTS-bob.xml" should contain:
+      """
+      <testsuite name="bob.Bob" tests="1" errors="0" failures="0" skipped="1" time="0.0">
+      """
+      # -- HINT FOR: Python < 3.8
+      # <testsuite errors="0" failures="0" name="bob.Bob" skipped="1" tests="1" time="0.0">
+
+  @not.with_python.version=3.8
   Scenario: Junit report for skipped scenario is neither shown nor counted with --no-skipped
     When I run "behave --junit -t @tag1 --no-skipped"
     Then it should pass with:
@@ -102,7 +120,30 @@ Feature: Issue #330: Skipped scenarios are included in junit reports when --no-s
       """
     And note that "Charly2 is the skipped scenarion in charly.feature"
 
+  @use.with_python.version=3.8
+  Scenario: Junit report for skipped scenario is neither shown nor counted with --no-skipped
+    When I run "behave --junit -t @tag1 --no-skipped"
+    Then it should pass with:
+      """
+      2 features passed, 0 failed, 1 skipped
+      2 scenarios passed, 0 failed, 2 skipped
+      """
+    And a file named "test_results/TESTS-alice.xml" exists
+    And a file named "test_results/TESTS-charly.xml" exists
+    And the file "test_results/TESTS-charly.xml" should contain:
+      """
+      <testsuite name="charly.Charly" tests="1" errors="0" failures="0" skipped="0"
+      """
+      # -- HINT FOR: Python < 3.8
+      # <testsuite errors="0" failures="0" name="charly.Charly" skipped="0" tests="1"
+    And the file "test_results/TESTS-charly.xml" should not contain:
+      """
+      <testcase classname="charly.Charly" name="Charly2"
+      """
+    And note that "Charly2 is the skipped scenarion in charly.feature"
+
 
+  @not.with_python.version=3.8
   Scenario: Junit report for skipped scenario is shown and counted with --show-skipped
     When I run "behave --junit -t @tag1 --show-skipped"
     Then it should pass with:
@@ -122,3 +163,26 @@ Feature: Issue #330: Skipped scenarios are included in junit reports when --no-s
       """
     And note that "Charly2 is the skipped scenarion in charly.feature"
 
+
+  @use.with_python.version=3.8
+  Scenario: Junit report for skipped scenario is shown and counted with --show-skipped
+    When I run "behave --junit -t @tag1 --show-skipped"
+    Then it should pass with:
+      """
+      2 features passed, 0 failed, 1 skipped
+      2 scenarios passed, 0 failed, 2 skipped
+      """
+    And a file named "test_results/TESTS-alice.xml" exists
+    And a file named "test_results/TESTS-charly.xml" exists
+    And the file "test_results/TESTS-charly.xml" should contain:
+      """
+      <testsuite name="charly.Charly" tests="2" errors="0" failures="0" skipped="1"
+      """
+      # HINT: Python < 3.8
+      # <testsuite errors="0" failures="0" name="charly.Charly" skipped="1" tests="2"
+    And the file "test_results/TESTS-charly.xml" should contain:
+      """
+      <testcase classname="charly.Charly" name="Charly2" status="skipped"
+      """
+    And note that "Charly2 is the skipped scenarion in charly.feature"
+
diff --git a/issue.features/issue0446.feature b/issue.features/issue0446.feature
index a2ed892d..901bdec5 100644
--- a/issue.features/issue0446.feature
+++ b/issue.features/issue0446.feature
@@ -58,6 +58,7 @@ Feature: Issue #446 -- Support scenario hook-errors with JUnitReporter
         behave.reporter.junit.show_hostname = False
         """
 
+    @not.with_python.version=3.8
     Scenario: Hook error in before_scenario()
       When I run "behave -f plain --junit features/before_scenario_failure.feature"
       Then it should fail with:
@@ -86,6 +87,40 @@ Feature: Issue #446 -- Support scenario hook-errors with JUnitReporter
       And note that "the traceback is contained in the XML element <error/>"
 
 
+    @use.with_python.version=3.8
+    Scenario: Hook error in before_scenario()
+      When I run "behave -f plain --junit features/before_scenario_failure.feature"
+      Then it should fail with:
+        """
+        0 scenarios passed, 1 failed, 0 skipped
+        """
+      And the command output should contain:
+        """
+        HOOK-ERROR in before_scenario: RuntimeError: OOPS
+        """
+      And the file "reports/TESTS-before_scenario_failure.xml" should contain:
+        """
+        <testsuite name="before_scenario_failure.Alice" tests="1" errors="1" failures="0" skipped="0"
+        """
+        # -- HINT FOR: Python < 3.8
+        # <testsuite errors="1" failures="0" name="before_scenario_failure.Alice" skipped="0" tests="1"
+      And the file "reports/TESTS-before_scenario_failure.xml" should contain:
+        """
+        <error type="RuntimeError" message="HOOK-ERROR in before_scenario: RuntimeError: OOPS">
+        """
+        # -- HINT FOR: Python < 3.8
+        # <error message="HOOK-ERROR in before_scenario: RuntimeError: OOPS" type="RuntimeError">
+      And the file "reports/TESTS-before_scenario_failure.xml" should contain:
+        """
+        File "features/environment.py", line 6, in before_scenario
+          cause_hook_failure()
+        File "features/environment.py", line 2, in cause_hook_failure
+          raise RuntimeError("OOPS")
+        """
+      And note that "the traceback is contained in the XML element <error/>"
+
+
+    @not.with_python.version=3.8
     Scenario: Hook error in after_scenario()
       When I run "behave -f plain --junit features/after_scenario_failure.feature"
       Then it should fail with:
@@ -114,3 +149,38 @@ Feature: Issue #446 -- Support scenario hook-errors with JUnitReporter
           raise RuntimeError("OOPS")
         """
       And note that "the traceback is contained in the XML element <error/>"
+
+
+    @use.with_python.version=3.8
+    Scenario: Hook error in after_scenario()
+      When I run "behave -f plain --junit features/after_scenario_failure.feature"
+      Then it should fail with:
+        """
+        0 scenarios passed, 1 failed, 0 skipped
+        """
+      And the command output should contain:
+        """
+          Scenario: B1
+            Given another step passes ... passed
+        HOOK-ERROR in after_scenario: RuntimeError: OOPS
+        """
+      And the file "reports/TESTS-after_scenario_failure.xml" should contain:
+        """
+        <testsuite name="after_scenario_failure.Bob" tests="1" errors="1" failures="0" skipped="0"
+        """
+        # -- HINT FOR: Python < 3.8
+        # <testsuite errors="1" failures="0" name="after_scenario_failure.Bob" skipped="0" tests="1"
+      And the file "reports/TESTS-after_scenario_failure.xml" should contain:
+        """
+        <error type="RuntimeError" message="HOOK-ERROR in after_scenario: RuntimeError: OOPS">
+        """
+        # -- HINT FOR: Python < 3.8
+        # <error message="HOOK-ERROR in after_scenario: RuntimeError: OOPS" type="RuntimeError">
+      And the file "reports/TESTS-after_scenario_failure.xml" should contain:
+        """
+        File "features/environment.py", line 10, in after_scenario
+          cause_hook_failure()
+        File "features/environment.py", line 2, in cause_hook_failure
+          raise RuntimeError("OOPS")
+        """
+      And note that "the traceback is contained in the XML element <error/>"
diff --git a/issue.features/issue0457.feature b/issue.features/issue0457.feature
index f80640e9..46f96e9c 100644
--- a/issue.features/issue0457.feature
+++ b/issue.features/issue0457.feature
@@ -24,6 +24,7 @@ Feature: Issue #457 -- Double-quotes in error messages of JUnit XML reports
         """
 
 
+    @not.with_python.version=3.8
     Scenario: Use failing assertation in a JUnit XML report
       Given a file named "features/fails1.feature" with:
         """
@@ -44,6 +45,31 @@ Feature: Issue #457 -- Double-quotes in error messages of JUnit XML reports
         <failure message="FAILED: My name is &quot;Alice&quot;"
         """
 
+    @use.with_python.version=3.8
+    Scenario: Use failing assertation in a JUnit XML report
+      Given a file named "features/fails1.feature" with:
+        """
+        Feature:
+          Scenario: Alice
+            Given a step fails with message:
+              '''
+              My name is "Alice"
+              '''
+        """
+      When I run "behave --junit features/fails1.feature"
+      Then it should fail with:
+        """
+        0 scenarios passed, 1 failed, 0 skipped
+        """
+      And the file "reports/TESTS-fails1.xml" should contain:
+        """
+        <failure type="AssertionError" message="FAILED: My name is &quot;Alice&quot;">
+        """
+        # -- HINT FOR: Python < 3.8
+        # <failure message="FAILED: My name is &quot;Alice&quot;"
+
+
+    @not.with_python.version=3.8
     Scenario: Use exception in a JUnit XML report
       Given a file named "features/fails2.feature" with:
         """
@@ -63,3 +89,26 @@ Feature: Issue #457 -- Double-quotes in error messages of JUnit XML reports
         """
         <error message="My name is &quot;Bob&quot; and &lt;here&gt; I am"
         """
+
+    @use.with_python.version=3.8
+    Scenario: Use exception in a JUnit XML report
+      Given a file named "features/fails2.feature" with:
+        """
+        Feature:
+          Scenario: Bob
+            Given a step fails with error and message:
+              '''
+              My name is "Bob" and <here> I am
+              '''
+        """
+      When I run "behave --junit features/fails2.feature"
+      Then it should fail with:
+        """
+        0 scenarios passed, 1 failed, 0 skipped
+        """
+      And the file "reports/TESTS-fails2.xml" should contain:
+        """
+        <error type="RuntimeError" message="My name is &quot;Bob&quot; and &lt;here&gt; I am">
+        """
+        # -- HINT FOR: Python < 3.8
+        # <error message="My name is &quot;Bob&quot; and &lt;here&gt; I am"