| 1 |
From 72257e2db209f60626e43a1335e656f868b72935 Mon Sep 17 00:00:00 2001 |
| 2 |
From: Petr Schindler <[email protected]> |
| 3 |
Date: Fri, 20 Sep 2019 08:38:18 +0200 |
| 4 |
Subject: [PATCH] Backport for py38 fixes |
| 5 |
|
| 6 |
Cherry picked from commits: |
| 7 |
83906ba779956af9437defcb8975debb18440e0d |
| 8 |
ce8f2eddd832b34fb4f628d898383db16f5c92ed |
| 9 |
e69d28ea8ce3bf361b278bfe5e10cafa6bdf6760 |
| 10 |
c000c88eb5239b87f299c85e83b349b0ef387ae7 |
| 11 |
|
| 12 |
--- |
| 13 |
behave.ini | 3 +- |
| 14 |
features/environment.py | 14 ++++++ |
| 15 |
features/step.duplicated_step.feature | 20 ++++---- |
| 16 |
issue.features/environment.py | 38 ++++++++++++--- |
| 17 |
issue.features/issue0330.feature | 64 ++++++++++++++++++++++++ |
| 18 |
issue.features/issue0446.feature | 70 +++++++++++++++++++++++++++ |
| 19 |
issue.features/issue0457.feature | 49 +++++++++++++++++++ |
| 20 |
test/test_runner.py | 6 +++ |
| 21 |
tests/api/_test_async_step34.py | 9 ++-- |
| 22 |
tests/unit/test_capture.py | 2 + |
| 23 |
tox.ini | 2 +- |
| 24 |
11 files changed, 255 insertions(+), 22 deletions(-) |
| 25 |
|
| 26 |
diff --git a/behave.ini b/behave.ini |
| 27 |
index 431956d..1a18843 100644 |
| 28 |
--- a/behave.ini |
| 29 |
+++ b/behave.ini |
| 30 |
@@ -15,8 +15,9 @@ show_skipped = false |
| 31 |
format = rerun |
| 32 |
progress3 |
| 33 |
outfiles = rerun.txt |
| 34 |
- reports/report_progress3.txt |
| 35 |
+ build/behave.reports/report_progress3.txt |
| 36 |
junit = true |
| 37 |
+junit_directory = build/behave.reports |
| 38 |
logging_level = INFO |
| 39 |
# logging_format = LOG.%(levelname)-8s %(name)-10s: %(message)s |
| 40 |
# logging_format = LOG.%(levelname)-8s %(asctime)s %(name)-10s: %(message)s |
| 41 |
diff --git a/features/environment.py b/features/environment.py |
| 42 |
index 4744e89..3769ee4 100644 |
| 43 |
--- a/features/environment.py |
| 44 |
+++ b/features/environment.py |
| 45 |
@@ -1,5 +1,7 @@ |
| 46 |
# -*- coding: UTF-8 -*- |
| 47 |
+# FILE: features/environemnt.py |
| 48 |
|
| 49 |
+from __future__ import absolute_import, print_function |
| 50 |
from behave.tag_matcher import ActiveTagMatcher, setup_active_tag_values |
| 51 |
from behave4cmd0.setup_command_shell import setup_command_shell_processors4behave |
| 52 |
import platform |
| 53 |
@@ -20,6 +22,15 @@ active_tag_value_provider = { |
| 54 |
} |
| 55 |
active_tag_matcher = ActiveTagMatcher(active_tag_value_provider) |
| 56 |
|
| 57 |
+ |
| 58 |
+def print_active_tags_summary(): |
| 59 |
+ active_tag_data = active_tag_value_provider |
| 60 |
+ print("ACTIVE-TAG SUMMARY:") |
| 61 |
+ print("use.with_python.version=%s" % active_tag_data.get("python.version")) |
| 62 |
+ # print("use.with_os=%s" % active_tag_data.get("os")) |
| 63 |
+ print() |
| 64 |
+ |
| 65 |
+ |
| 66 |
# ----------------------------------------------------------------------------- |
| 67 |
# HOOKS: |
| 68 |
# ----------------------------------------------------------------------------- |
| 69 |
@@ -30,11 +41,14 @@ def before_all(context): |
| 70 |
setup_python_path() |
| 71 |
setup_context_with_global_params_test(context) |
| 72 |
setup_command_shell_processors4behave() |
| 73 |
+ print_active_tags_summary() |
| 74 |
+ |
| 75 |
|
| 76 |
def before_feature(context, feature): |
| 77 |
if active_tag_matcher.should_exclude_with(feature.tags): |
| 78 |
feature.skip(reason=active_tag_matcher.exclude_reason) |
| 79 |
|
| 80 |
+ |
| 81 |
def before_scenario(context, scenario): |
| 82 |
if active_tag_matcher.should_exclude_with(scenario.effective_tags): |
| 83 |
scenario.skip(reason=active_tag_matcher.exclude_reason) |
| 84 |
diff --git a/features/step.duplicated_step.feature b/features/step.duplicated_step.feature |
| 85 |
index 59888b0..396cca2 100644 |
| 86 |
--- a/features/step.duplicated_step.feature |
| 87 |
+++ b/features/step.duplicated_step.feature |
| 88 |
@@ -32,11 +32,11 @@ Feature: Duplicated Step Definitions |
| 89 |
AmbiguousStep: @given('I call Alice') has already been defined in |
| 90 |
existing step @given('I call Alice') at features/steps/alice_steps.py:3 |
| 91 |
""" |
| 92 |
- And the command output should contain: |
| 93 |
- """ |
| 94 |
- File "features/steps/alice_steps.py", line 7, in <module> |
| 95 |
- @given(u'I call Alice') |
| 96 |
- """ |
| 97 |
+ # -- DISABLED: Python 3.8 traceback line numbers differ w/ decorators (+1). |
| 98 |
+ # And the command output should contain: |
| 99 |
+ # """ |
| 100 |
+ # File "features/steps/alice_steps.py", line 7, in <module> |
| 101 |
+ # """ |
| 102 |
|
| 103 |
|
| 104 |
Scenario: Duplicated Step Definition in another File |
| 105 |
@@ -70,11 +70,11 @@ Feature: Duplicated Step Definitions |
| 106 |
AmbiguousStep: @given('I call Bob') has already been defined in |
| 107 |
existing step @given('I call Bob') at features/steps/bob1_steps.py:3 |
| 108 |
""" |
| 109 |
- And the command output should contain: |
| 110 |
- """ |
| 111 |
- File "features/steps/bob2_steps.py", line 3, in <module> |
| 112 |
- @given('I call Bob') |
| 113 |
- """ |
| 114 |
+ # -- DISABLED: Python 3.8 traceback line numbers differ w/ decorators (+1). |
| 115 |
+ # And the command output should contain: |
| 116 |
+ # """ |
| 117 |
+ # File "features/steps/bob2_steps.py", line 3, in <module> |
| 118 |
+ # """ |
| 119 |
|
| 120 |
@xfail |
| 121 |
Scenario: Duplicated Same Step Definition via import from another File |
| 122 |
diff --git a/issue.features/environment.py b/issue.features/environment.py |
| 123 |
index 3737155..dc8a7fb 100644 |
| 124 |
--- a/issue.features/environment.py |
| 125 |
+++ b/issue.features/environment.py |
| 126 |
@@ -1,5 +1,5 @@ |
| 127 |
# -*- coding: UTF-8 -*- |
| 128 |
-# FILE: features/environment.py |
| 129 |
+# FILE: issue.features/environemnt.py |
| 130 |
# pylint: disable=unused-argument |
| 131 |
""" |
| 132 |
Functionality: |
| 133 |
@@ -7,17 +7,20 @@ Functionality: |
| 134 |
* active tags |
| 135 |
""" |
| 136 |
|
| 137 |
-from __future__ import print_function |
| 138 |
+ |
| 139 |
+from __future__ import absolute_import, print_function |
| 140 |
import sys |
| 141 |
import platform |
| 142 |
import os.path |
| 143 |
import six |
| 144 |
from behave.tag_matcher import ActiveTagMatcher |
| 145 |
from behave4cmd0.setup_command_shell import setup_command_shell_processors4behave |
| 146 |
-# PREPARED: |
| 147 |
-# from behave.tag_matcher import setup_active_tag_values |
| 148 |
+# PREPARED: from behave.tag_matcher import setup_active_tag_values |
| 149 |
|
| 150 |
|
| 151 |
+# --------------------------------------------------------------------------- |
| 152 |
+# TEST SUPPORT: For Active Tags |
| 153 |
+# --------------------------------------------------------------------------- |
| 154 |
def require_tool(tool_name): |
| 155 |
"""Check if a tool (an executable program) is provided on this platform. |
| 156 |
|
| 157 |
@@ -45,12 +48,14 @@ def require_tool(tool_name): |
| 158 |
# print("TOOL-NOT-FOUND: %s" % tool_name) |
| 159 |
return False |
| 160 |
|
| 161 |
+ |
| 162 |
def as_bool_string(value): |
| 163 |
if bool(value): |
| 164 |
return "yes" |
| 165 |
else: |
| 166 |
return "no" |
| 167 |
|
| 168 |
+ |
| 169 |
def discover_ci_server(): |
| 170 |
# pylint: disable=invalid-name |
| 171 |
ci_server = "none" |
| 172 |
@@ -67,11 +72,16 @@ def discover_ci_server(): |
| 173 |
return ci_server |
| 174 |
|
| 175 |
|
| 176 |
+# --------------------------------------------------------------------------- |
| 177 |
+# BEHAVE SUPPORT: Active Tags |
| 178 |
+# --------------------------------------------------------------------------- |
| 179 |
# -- MATCHES ANY TAGS: @use.with_{category}={value} |
| 180 |
# NOTE: active_tag_value_provider provides category values for active tags. |
| 181 |
+python_version = "%s.%s" % sys.version_info[:2] |
| 182 |
active_tag_value_provider = { |
| 183 |
"python2": str(six.PY2).lower(), |
| 184 |
"python3": str(six.PY3).lower(), |
| 185 |
+ "python.version": python_version, |
| 186 |
# -- python.implementation: cpython, pypy, jython, ironpython |
| 187 |
"python.implementation": platform.python_implementation().lower(), |
| 188 |
"pypy": str("__pypy__" in sys.modules).lower(), |
| 189 |
@@ -81,17 +91,33 @@ active_tag_value_provider = { |
| 190 |
} |
| 191 |
active_tag_matcher = ActiveTagMatcher(active_tag_value_provider) |
| 192 |
|
| 193 |
+ |
| 194 |
+def print_active_tags_summary(): |
| 195 |
+ active_tag_data = active_tag_value_provider |
| 196 |
+ print("ACTIVE-TAG SUMMARY:") |
| 197 |
+ print("use.with_python.version=%s" % active_tag_data.get("python.version")) |
| 198 |
+ # print("use.with_platform=%s" % active_tag_data.get("platform")) |
| 199 |
+ # print("use.with_os=%s" % active_tag_data.get("os")) |
| 200 |
+ print() |
| 201 |
+ |
| 202 |
+ |
| 203 |
+# --------------------------------------------------------------------------- |
| 204 |
+# BEHAVE HOOKS: |
| 205 |
+# --------------------------------------------------------------------------- |
| 206 |
def before_all(context): |
| 207 |
# -- SETUP ACTIVE-TAG MATCHER (with userdata): |
| 208 |
# USE: behave -D browser=safari ... |
| 209 |
- # NOT-NEEDED: setup_active_tag_values(active_tag_value_provider, |
| 210 |
- # context.config.userdata) |
| 211 |
+ # NOT-NEEDED: |
| 212 |
+ # setup_active_tag_values(active_tag_value_provider, context.config.userdata) |
| 213 |
setup_command_shell_processors4behave() |
| 214 |
+ print_active_tags_summary() |
| 215 |
+ |
| 216 |
|
| 217 |
def before_feature(context, feature): |
| 218 |
if active_tag_matcher.should_exclude_with(feature.tags): |
| 219 |
feature.skip(reason=active_tag_matcher.exclude_reason) |
| 220 |
|
| 221 |
+ |
| 222 |
def before_scenario(context, scenario): |
| 223 |
if active_tag_matcher.should_exclude_with(scenario.effective_tags): |
| 224 |
scenario.skip(reason=active_tag_matcher.exclude_reason) |
| 225 |
diff --git a/issue.features/issue0330.feature b/issue.features/issue0330.feature |
| 226 |
index dc1ebe7..81cb6e2 100644 |
| 227 |
--- a/issue.features/issue0330.feature |
| 228 |
+++ b/issue.features/issue0330.feature |
| 229 |
@@ -70,6 +70,7 @@ Feature: Issue #330: Skipped scenarios are included in junit reports when --no-s |
| 230 |
And note that "bob.feature is skipped" |
| 231 |
|
| 232 |
|
| 233 |
+ @not.with_python.version=3.8 |
| 234 |
Scenario: Junit report for skipped feature is created with --show-skipped |
| 235 |
When I run "behave --junit -t @tag1 --show-skipped @alice_and_bob.featureset" |
| 236 |
Then it should pass with: |
| 237 |
@@ -83,6 +84,23 @@ Feature: Issue #330: Skipped scenarios are included in junit reports when --no-s |
| 238 |
<testsuite errors="0" failures="0" name="bob.Bob" skipped="1" tests="1" time="0.0"> |
| 239 |
""" |
| 240 |
|
| 241 |
+ @use.with_python.version=3.8 |
| 242 |
+ Scenario: Junit report for skipped feature is created with --show-skipped |
| 243 |
+ When I run "behave --junit -t @tag1 --show-skipped @alice_and_bob.featureset" |
| 244 |
+ Then it should pass with: |
| 245 |
+ """ |
| 246 |
+ 1 feature passed, 0 failed, 1 skipped |
| 247 |
+ """ |
| 248 |
+ And a file named "test_results/TESTS-alice.xml" exists |
| 249 |
+ And a file named "test_results/TESTS-bob.xml" exists |
| 250 |
+ And the file "test_results/TESTS-bob.xml" should contain: |
| 251 |
+ """ |
| 252 |
+ <testsuite name="bob.Bob" tests="1" errors="0" failures="0" skipped="1" time="0.0"> |
| 253 |
+ """ |
| 254 |
+ # -- HINT FOR: Python < 3.8 |
| 255 |
+ # <testsuite errors="0" failures="0" name="bob.Bob" skipped="1" tests="1" time="0.0"> |
| 256 |
+ |
| 257 |
+ @not.with_python.version=3.8 |
| 258 |
Scenario: Junit report for skipped scenario is neither shown nor counted with --no-skipped |
| 259 |
When I run "behave --junit -t @tag1 --no-skipped" |
| 260 |
Then it should pass with: |
| 261 |
@@ -102,7 +120,30 @@ Feature: Issue #330: Skipped scenarios are included in junit reports when --no-s |
| 262 |
""" |
| 263 |
And note that "Charly2 is the skipped scenarion in charly.feature" |
| 264 |
|
| 265 |
+ @use.with_python.version=3.8 |
| 266 |
+ Scenario: Junit report for skipped scenario is neither shown nor counted with --no-skipped |
| 267 |
+ When I run "behave --junit -t @tag1 --no-skipped" |
| 268 |
+ Then it should pass with: |
| 269 |
+ """ |
| 270 |
+ 2 features passed, 0 failed, 1 skipped |
| 271 |
+ 2 scenarios passed, 0 failed, 2 skipped |
| 272 |
+ """ |
| 273 |
+ And a file named "test_results/TESTS-alice.xml" exists |
| 274 |
+ And a file named "test_results/TESTS-charly.xml" exists |
| 275 |
+ And the file "test_results/TESTS-charly.xml" should contain: |
| 276 |
+ """ |
| 277 |
+ <testsuite name="charly.Charly" tests="1" errors="0" failures="0" skipped="0" |
| 278 |
+ """ |
| 279 |
+ # -- HINT FOR: Python < 3.8 |
| 280 |
+ # <testsuite errors="0" failures="0" name="charly.Charly" skipped="0" tests="1" |
| 281 |
+ And the file "test_results/TESTS-charly.xml" should not contain: |
| 282 |
+ """ |
| 283 |
+ <testcase classname="charly.Charly" name="Charly2" |
| 284 |
+ """ |
| 285 |
+ And note that "Charly2 is the skipped scenarion in charly.feature" |
| 286 |
+ |
| 287 |
|
| 288 |
+ @not.with_python.version=3.8 |
| 289 |
Scenario: Junit report for skipped scenario is shown and counted with --show-skipped |
| 290 |
When I run "behave --junit -t @tag1 --show-skipped" |
| 291 |
Then it should pass with: |
| 292 |
@@ -122,3 +163,26 @@ Feature: Issue #330: Skipped scenarios are included in junit reports when --no-s |
| 293 |
""" |
| 294 |
And note that "Charly2 is the skipped scenarion in charly.feature" |
| 295 |
|
| 296 |
+ |
| 297 |
+ @use.with_python.version=3.8 |
| 298 |
+ Scenario: Junit report for skipped scenario is shown and counted with --show-skipped |
| 299 |
+ When I run "behave --junit -t @tag1 --show-skipped" |
| 300 |
+ Then it should pass with: |
| 301 |
+ """ |
| 302 |
+ 2 features passed, 0 failed, 1 skipped |
| 303 |
+ 2 scenarios passed, 0 failed, 2 skipped |
| 304 |
+ """ |
| 305 |
+ And a file named "test_results/TESTS-alice.xml" exists |
| 306 |
+ And a file named "test_results/TESTS-charly.xml" exists |
| 307 |
+ And the file "test_results/TESTS-charly.xml" should contain: |
| 308 |
+ """ |
| 309 |
+ <testsuite name="charly.Charly" tests="2" errors="0" failures="0" skipped="1" |
| 310 |
+ """ |
| 311 |
+ # HINT: Python < 3.8 |
| 312 |
+ # <testsuite errors="0" failures="0" name="charly.Charly" skipped="1" tests="2" |
| 313 |
+ And the file "test_results/TESTS-charly.xml" should contain: |
| 314 |
+ """ |
| 315 |
+ <testcase classname="charly.Charly" name="Charly2" status="skipped" |
| 316 |
+ """ |
| 317 |
+ And note that "Charly2 is the skipped scenarion in charly.feature" |
| 318 |
+ |
| 319 |
diff --git a/issue.features/issue0446.feature b/issue.features/issue0446.feature |
| 320 |
index a2ed892..901bdec 100644 |
| 321 |
--- a/issue.features/issue0446.feature |
| 322 |
+++ b/issue.features/issue0446.feature |
| 323 |
@@ -58,6 +58,7 @@ Feature: Issue #446 -- Support scenario hook-errors with JUnitReporter |
| 324 |
behave.reporter.junit.show_hostname = False |
| 325 |
""" |
| 326 |
|
| 327 |
+ @not.with_python.version=3.8 |
| 328 |
Scenario: Hook error in before_scenario() |
| 329 |
When I run "behave -f plain --junit features/before_scenario_failure.feature" |
| 330 |
Then it should fail with: |
| 331 |
@@ -86,6 +87,40 @@ Feature: Issue #446 -- Support scenario hook-errors with JUnitReporter |
| 332 |
And note that "the traceback is contained in the XML element <error/>" |
| 333 |
|
| 334 |
|
| 335 |
+ @use.with_python.version=3.8 |
| 336 |
+ Scenario: Hook error in before_scenario() |
| 337 |
+ When I run "behave -f plain --junit features/before_scenario_failure.feature" |
| 338 |
+ Then it should fail with: |
| 339 |
+ """ |
| 340 |
+ 0 scenarios passed, 1 failed, 0 skipped |
| 341 |
+ """ |
| 342 |
+ And the command output should contain: |
| 343 |
+ """ |
| 344 |
+ HOOK-ERROR in before_scenario: RuntimeError: OOPS |
| 345 |
+ """ |
| 346 |
+ And the file "reports/TESTS-before_scenario_failure.xml" should contain: |
| 347 |
+ """ |
| 348 |
+ <testsuite name="before_scenario_failure.Alice" tests="1" errors="1" failures="0" skipped="0" |
| 349 |
+ """ |
| 350 |
+ # -- HINT FOR: Python < 3.8 |
| 351 |
+ # <testsuite errors="1" failures="0" name="before_scenario_failure.Alice" skipped="0" tests="1" |
| 352 |
+ And the file "reports/TESTS-before_scenario_failure.xml" should contain: |
| 353 |
+ """ |
| 354 |
+ <error type="RuntimeError" message="HOOK-ERROR in before_scenario: RuntimeError: OOPS"> |
| 355 |
+ """ |
| 356 |
+ # -- HINT FOR: Python < 3.8 |
| 357 |
+ # <error message="HOOK-ERROR in before_scenario: RuntimeError: OOPS" type="RuntimeError"> |
| 358 |
+ And the file "reports/TESTS-before_scenario_failure.xml" should contain: |
| 359 |
+ """ |
| 360 |
+ File "features/environment.py", line 6, in before_scenario |
| 361 |
+ cause_hook_failure() |
| 362 |
+ File "features/environment.py", line 2, in cause_hook_failure |
| 363 |
+ raise RuntimeError("OOPS") |
| 364 |
+ """ |
| 365 |
+ And note that "the traceback is contained in the XML element <error/>" |
| 366 |
+ |
| 367 |
+ |
| 368 |
+ @not.with_python.version=3.8 |
| 369 |
Scenario: Hook error in after_scenario() |
| 370 |
When I run "behave -f plain --junit features/after_scenario_failure.feature" |
| 371 |
Then it should fail with: |
| 372 |
@@ -114,3 +149,38 @@ Feature: Issue #446 -- Support scenario hook-errors with JUnitReporter |
| 373 |
raise RuntimeError("OOPS") |
| 374 |
""" |
| 375 |
And note that "the traceback is contained in the XML element <error/>" |
| 376 |
+ |
| 377 |
+ |
| 378 |
+ @use.with_python.version=3.8 |
| 379 |
+ Scenario: Hook error in after_scenario() |
| 380 |
+ When I run "behave -f plain --junit features/after_scenario_failure.feature" |
| 381 |
+ Then it should fail with: |
| 382 |
+ """ |
| 383 |
+ 0 scenarios passed, 1 failed, 0 skipped |
| 384 |
+ """ |
| 385 |
+ And the command output should contain: |
| 386 |
+ """ |
| 387 |
+ Scenario: B1 |
| 388 |
+ Given another step passes ... passed |
| 389 |
+ HOOK-ERROR in after_scenario: RuntimeError: OOPS |
| 390 |
+ """ |
| 391 |
+ And the file "reports/TESTS-after_scenario_failure.xml" should contain: |
| 392 |
+ """ |
| 393 |
+ <testsuite name="after_scenario_failure.Bob" tests="1" errors="1" failures="0" skipped="0" |
| 394 |
+ """ |
| 395 |
+ # -- HINT FOR: Python < 3.8 |
| 396 |
+ # <testsuite errors="1" failures="0" name="after_scenario_failure.Bob" skipped="0" tests="1" |
| 397 |
+ And the file "reports/TESTS-after_scenario_failure.xml" should contain: |
| 398 |
+ """ |
| 399 |
+ <error type="RuntimeError" message="HOOK-ERROR in after_scenario: RuntimeError: OOPS"> |
| 400 |
+ """ |
| 401 |
+ # -- HINT FOR: Python < 3.8 |
| 402 |
+ # <error message="HOOK-ERROR in after_scenario: RuntimeError: OOPS" type="RuntimeError"> |
| 403 |
+ And the file "reports/TESTS-after_scenario_failure.xml" should contain: |
| 404 |
+ """ |
| 405 |
+ File "features/environment.py", line 10, in after_scenario |
| 406 |
+ cause_hook_failure() |
| 407 |
+ File "features/environment.py", line 2, in cause_hook_failure |
| 408 |
+ raise RuntimeError("OOPS") |
| 409 |
+ """ |
| 410 |
+ And note that "the traceback is contained in the XML element <error/>" |
| 411 |
diff --git a/issue.features/issue0457.feature b/issue.features/issue0457.feature |
| 412 |
index f80640e..46f96e9 100644 |
| 413 |
--- a/issue.features/issue0457.feature |
| 414 |
+++ b/issue.features/issue0457.feature |
| 415 |
@@ -24,6 +24,7 @@ Feature: Issue #457 -- Double-quotes in error messages of JUnit XML reports |
| 416 |
""" |
| 417 |
|
| 418 |
|
| 419 |
+ @not.with_python.version=3.8 |
| 420 |
Scenario: Use failing assertation in a JUnit XML report |
| 421 |
Given a file named "features/fails1.feature" with: |
| 422 |
""" |
| 423 |
@@ -44,6 +45,31 @@ Feature: Issue #457 -- Double-quotes in error messages of JUnit XML reports |
| 424 |
<failure message="FAILED: My name is "Alice"" |
| 425 |
""" |
| 426 |
|
| 427 |
+ @use.with_python.version=3.8 |
| 428 |
+ Scenario: Use failing assertation in a JUnit XML report |
| 429 |
+ Given a file named "features/fails1.feature" with: |
| 430 |
+ """ |
| 431 |
+ Feature: |
| 432 |
+ Scenario: Alice |
| 433 |
+ Given a step fails with message: |
| 434 |
+ ''' |
| 435 |
+ My name is "Alice" |
| 436 |
+ ''' |
| 437 |
+ """ |
| 438 |
+ When I run "behave --junit features/fails1.feature" |
| 439 |
+ Then it should fail with: |
| 440 |
+ """ |
| 441 |
+ 0 scenarios passed, 1 failed, 0 skipped |
| 442 |
+ """ |
| 443 |
+ And the file "reports/TESTS-fails1.xml" should contain: |
| 444 |
+ """ |
| 445 |
+ <failure type="AssertionError" message="FAILED: My name is "Alice""> |
| 446 |
+ """ |
| 447 |
+ # -- HINT FOR: Python < 3.8 |
| 448 |
+ # <failure message="FAILED: My name is "Alice"" |
| 449 |
+ |
| 450 |
+ |
| 451 |
+ @not.with_python.version=3.8 |
| 452 |
Scenario: Use exception in a JUnit XML report |
| 453 |
Given a file named "features/fails2.feature" with: |
| 454 |
""" |
| 455 |
@@ -63,3 +89,26 @@ Feature: Issue #457 -- Double-quotes in error messages of JUnit XML reports |
| 456 |
""" |
| 457 |
<error message="My name is "Bob" and <here> I am" |
| 458 |
""" |
| 459 |
+ |
| 460 |
+ @use.with_python.version=3.8 |
| 461 |
+ Scenario: Use exception in a JUnit XML report |
| 462 |
+ Given a file named "features/fails2.feature" with: |
| 463 |
+ """ |
| 464 |
+ Feature: |
| 465 |
+ Scenario: Bob |
| 466 |
+ Given a step fails with error and message: |
| 467 |
+ ''' |
| 468 |
+ My name is "Bob" and <here> I am |
| 469 |
+ ''' |
| 470 |
+ """ |
| 471 |
+ When I run "behave --junit features/fails2.feature" |
| 472 |
+ Then it should fail with: |
| 473 |
+ """ |
| 474 |
+ 0 scenarios passed, 1 failed, 0 skipped |
| 475 |
+ """ |
| 476 |
+ And the file "reports/TESTS-fails2.xml" should contain: |
| 477 |
+ """ |
| 478 |
+ <error type="RuntimeError" message="My name is "Bob" and <here> I am"> |
| 479 |
+ """ |
| 480 |
+ # -- HINT FOR: Python < 3.8 |
| 481 |
+ # <error message="My name is "Bob" and <here> I am" |
| 482 |
diff --git a/test/test_runner.py b/test/test_runner.py |
| 483 |
index 70a7002..1b5afa2 100644 |
| 484 |
--- a/test/test_runner.py |
| 485 |
+++ b/test/test_runner.py |
| 486 |
@@ -286,6 +286,7 @@ class TestContext(unittest.TestCase): |
| 487 |
eq_("thing" in self.context, True) |
| 488 |
del self.context.thing |
| 489 |
|
| 490 |
+ |
| 491 |
class ExampleSteps(object): |
| 492 |
text = None |
| 493 |
table = None |
| 494 |
@@ -320,6 +321,7 @@ class ExampleSteps(object): |
| 495 |
for keyword, pattern, func in step_definitions: |
| 496 |
step_registry.add_step_definition(keyword, pattern, func) |
| 497 |
|
| 498 |
+ |
| 499 |
class TestContext_ExecuteSteps(unittest.TestCase): |
| 500 |
""" |
| 501 |
Test the behave.runner.Context.execute_steps() functionality. |
| 502 |
@@ -341,6 +343,8 @@ class TestContext_ExecuteSteps(unittest.TestCase): |
| 503 |
runner_.config.stdout_capture = False |
| 504 |
runner_.config.stderr_capture = False |
| 505 |
runner_.config.log_capture = False |
| 506 |
+ runner_.config.logging_format = None |
| 507 |
+ runner_.config.logging_datefmt = None |
| 508 |
runner_.step_registry = self.step_registry |
| 509 |
|
| 510 |
self.context = runner.Context(runner_) |
| 511 |
@@ -658,6 +662,8 @@ class TestRunWithPaths(unittest.TestCase): |
| 512 |
self.config.logging_filter = None |
| 513 |
self.config.outputs = [Mock(), StreamOpener(stream=sys.stdout)] |
| 514 |
self.config.format = ["plain", "progress"] |
| 515 |
+ self.config.logging_format = None |
| 516 |
+ self.config.logging_datefmt = None |
| 517 |
self.runner = runner.Runner(self.config) |
| 518 |
self.load_hooks = self.runner.load_hooks = Mock() |
| 519 |
self.load_step_definitions = self.runner.load_step_definitions = Mock() |
| 520 |
diff --git a/tests/api/_test_async_step34.py b/tests/api/_test_async_step34.py |
| 521 |
index c93fb74..4e4edf4 100644 |
| 522 |
--- a/tests/api/_test_async_step34.py |
| 523 |
+++ b/tests/api/_test_async_step34.py |
| 524 |
@@ -37,15 +37,16 @@ from .testing_support_async import AsyncStepTheory |
| 525 |
# ----------------------------------------------------------------------------- |
| 526 |
# TEST MARKERS: |
| 527 |
# ----------------------------------------------------------------------------- |
| 528 |
-python_version = float("%s.%s" % sys.version_info[:2]) |
| 529 |
+# DEPRECATED: @asyncio.coroutine decorator (since: Python >= 3.8) |
| 530 |
+_python_version = float("%s.%s" % sys.version_info[:2]) |
| 531 |
+requires_py34_to_py37 = pytest.mark.skipif(not (3.4 <= _python_version < 3.8), |
| 532 |
+ reason="Supported only for python.versions: 3.4 .. 3.7 (inclusive)") |
| 533 |
|
| 534 |
-# xfail = pytest.mark.xfail |
| 535 |
-py34_or_newer = pytest.mark.skipif(python_version < 3.4, reason="Needs Python >= 3.4") |
| 536 |
|
| 537 |
# ----------------------------------------------------------------------------- |
| 538 |
# TESTSUITE: |
| 539 |
# ----------------------------------------------------------------------------- |
| 540 |
-@py34_or_newer |
| 541 |
+@requires_py34_to_py37 |
| 542 |
class TestAsyncStepDecorator34(object): |
| 543 |
|
| 544 |
def test_step_decorator_async_run_until_complete2(self): |
| 545 |
diff --git a/tests/unit/test_capture.py b/tests/unit/test_capture.py |
| 546 |
index ac2655e..d9a3f3a 100644 |
| 547 |
--- a/tests/unit/test_capture.py |
| 548 |
+++ b/tests/unit/test_capture.py |
| 549 |
@@ -20,6 +20,8 @@ def create_capture_controller(config=None): |
| 550 |
config.log_capture = True |
| 551 |
config.logging_filter = None |
| 552 |
config.logging_level = "INFO" |
| 553 |
+ config.logging_format = "%(levelname)s:%(name)s:%(message)s" |
| 554 |
+ config.logging_datefmt = None |
| 555 |
return CaptureController(config) |
| 556 |
|
| 557 |
def setup_capture_controller(capture_controller, context=None): |
| 558 |
diff --git a/tox.ini b/tox.ini |
| 559 |
index 92f6679..16a392c 100644 |
| 560 |
--- a/tox.ini |
| 561 |
+++ b/tox.ini |
| 562 |
@@ -28,7 +28,7 @@ |
| 563 |
|
| 564 |
[tox] |
| 565 |
minversion = 2.3 |
| 566 |
-envlist = py26, py27, py33, py34, py35, py36, pypy, docs |
| 567 |
+envlist = py26, py27, py33, py34, py35, py36, py37, py38, pypy, docs |
| 568 |
skip_missing_interpreters = True |
| 569 |
sitepackages = False |
| 570 |
indexserver = |
| 571 |
-- |
| 572 |
2.23.0 |
| 573 |
|