Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow bypassing expected failures #24

Merged
merged 2 commits into from Oct 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -38,5 +38,8 @@ Any pygame-cffi discussion welcome!
## Running Tests

* Upstream pygame unit tests: `python -m test`
* Tests that are known to fail on pygame_cffi are marked as expected
failures. To see these failures, pass the `--expected-failures`
argument.
* Conformance between pygame and pygame_cffi: See `conformance/README`
* pygame_cffi functionality example apps are in the `demos` directory
2 changes: 2 additions & 0 deletions test/__main__.py
Expand Up @@ -98,6 +98,8 @@
kwds = {}
if options.incomplete:
kwds['incomplete'] = True
if options.expected_failures:
kwds['expected_failures'] = True
if options.nosubprocess:
kwds['nosubprocess'] = True
if options.dump:
Expand Down
7 changes: 7 additions & 0 deletions test/test_utils/__init__.py
Expand Up @@ -219,9 +219,14 @@ def test():
################################################################################
# pygame_cffi additions:

fail_expected_failures = 0


def expected_failure(func):
@wraps(func)
def wrapper(*args, **kwargs):
if fail_expected_failures:
return func(*args, **kwargs)
try:
return func(*args, **kwargs)
except AssertionError:
Expand All @@ -234,6 +239,8 @@ def expected_error(exception):
def decorate(func):
@wraps(func)
def wrapper(*args, **kwargs):
if fail_expected_failures:
return func(*args, **kwargs)
try:
return func(*args, **kwargs)
except exception:
Expand Down
1 change: 1 addition & 0 deletions test/test_utils/run_tests.py
Expand Up @@ -243,6 +243,7 @@ def run(*args, **kwds):
pass_on_args.append('--%s' % option)
pass_on_args.append(str(value))
for option, value in options.items():
option = option.replace('_', '-')
if value:
pass_on_args.append('--%s' % option)

Expand Down
8 changes: 8 additions & 0 deletions test/test_utils/test_runner.py
Expand Up @@ -71,6 +71,11 @@ def exclude_callback(option, opt, value, parser):
"-i", "--incomplete", action = 'store_true',
help = "fail incomplete tests" )

opt_parser.add_option (
"-E", "--expected-failures", action = 'store_true',
help = "fail tests that are marked as expected failures "
"(incomplete implementations in pygame_cffi)" )

opt_parser.add_option (
"-n", "--nosubprocess", action = "store_true",
help = "run everything in a single process "
Expand Down Expand Up @@ -258,10 +263,12 @@ def run_test(module, **kwds):
"""

option_incomplete = kwds.get('incomplete', False)
option_expected_failures = kwds.get('expected_failures', False)
option_nosubprocess = kwds.get('nosubprocess', False)

suite = unittest.TestSuite()
test_utils.fail_incomplete_tests = option_incomplete
test_utils.fail_expected_failures = option_expected_failures

m = import_submodule(module)
if m.unittest is not unittest:
Expand Down Expand Up @@ -315,6 +322,7 @@ def run_test(module, **kwds):
sys.exit('No test module provided; consider using %s instead' % run_from)
run_test(args[0],
incomplete=options.incomplete,
expected_failures=options.expected_failures,
nosubprocess=options.nosubprocess)

################################################################################
Expand Down