diff --git a/.travis.yml b/.travis.yml index 587b83da..a0570c74 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,19 @@ matrix: include: - python: "3.6" env: TRAVIS_PYLINT=true + - os: windows + language: sh + python: "3.7" + before_install: + - choco install python3 + - export PATH="/c/Python37:/c/Python37/Scripts:$PATH" + - python -m pip install --upgrade pip wheel + script: + - python -m virtualenv .env + - .env/Scripts/pip.exe install -e .[testing,doc] + - .env/Scripts/py.test.exe --cov=slash --cov-report=html tests + allow_failures: + - os: windows # command to run tests, e.g. python setup.py test install: diff --git a/doc/changelog.rst b/doc/changelog.rst index 96004852..e1f80955 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -1,6 +1,9 @@ Changelog ========= +* :release:`1.7.8 <04-03-2019>` +* :bug:`925` Fix background color for session start and test collection messages +* :bug:`926` Return code for failed sessions was changed to 1 (from -1) * :release:`1.7.7 <21-01-2019>` * :bug:`907` Fix parallel worker timeout issues * :bug:`-` Fix test_start triggering when exceptions are thrown in class-based tests (thanks @pierreluctg) diff --git a/slash/app.py b/slash/app.py index 01318890..b9117127 100644 --- a/slash/app.py +++ b/slash/app.py @@ -145,7 +145,7 @@ def __exit__(self, exc_type, exc_value, exc_tb): except Exception as e: # pylint: disable=broad-except _logger.error("Failed to debug_if_needed: {!r}", e, exc_info=True, extra={'capture': False}) if exc_value is not None: - self._exit_code = exc_value.code if isinstance(exc_value, SystemExit) else -1 + self._exit_code = exc_value.code if isinstance(exc_value, SystemExit) else 1 if should_inhibit_unhandled_exception_traceback(exc_value): self.get_reporter().report_error_message(str(exc_value)) diff --git a/slash/frontend/slash_run.py b/slash/frontend/slash_run.py index d30b4ce5..12158e34 100644 --- a/slash/frontend/slash_run.py +++ b/slash/frontend/slash_run.py @@ -73,7 +73,7 @@ def slash_run(args, report_stream=None, resume=False, rerun=False, app_callback= save_resume_state(app.session.results, collected) clean_old_entries() if app.exit_code == 0 and not app.session.results.is_success(allow_skips=True): - app.set_exit_code(-1) + app.set_exit_code(1) except Exception: # pylint: disable=broad-except # Error reporting happens in app context assert app.exit_code != 0 diff --git a/slash/reporting/console_reporter.py b/slash/reporting/console_reporter.py index 2d0be039..a284ef84 100644 --- a/slash/reporting/console_reporter.py +++ b/slash/reporting/console_reporter.py @@ -166,14 +166,14 @@ def _report_num_collected(self, collected, stillworking): return self._terminal.write('{} tests collected{}'.format( - len(collected), '...' if stillworking else ' \n'), white=True, bold=True) + len(collected), '...' if stillworking else ' \n'), white=True, bold=True, Black=True) def _is_verbose(self, level): return self._level <= level @from_verbosity(VERBOSITIES.ERROR) def report_session_start(self, session): - self._terminal.sep('=', 'Session starts', white=True, bold=True) + self._terminal.sep('=', 'Session starts', white=True, bold=True, Black=True) def report_session_end(self, session): diff --git a/tests/test_logging.py b/tests/test_logging.py index 26e2c819..65f41dc7 100644 --- a/tests/test_logging.py +++ b/tests/test_logging.py @@ -1,6 +1,7 @@ # pylint: disable=unused-argument,redefined-outer-name import functools import os +import sys import logbook import brotli @@ -45,7 +46,7 @@ def test_with_log_error(): assert [res.message for res in result.get_errors()] == expected_error_messages assert [rec.message for rec in test_handler.records] == [message, non_capture_message] - +@pytest.mark.skipif(sys.platform == 'win32', reason="does not run on windows") def test_last_session_symlinks(files_dir, links_dir, session): test_log_file = files_dir.join( @@ -154,7 +155,7 @@ def test_log_symlinks_without_root_path(suite, config_override, symlink_name): config_override('log.{}'.format(symlink_name), 'some/subdir') assert suite.run().ok() - +@pytest.mark.skipif(sys.platform == 'win32', reason="does not run on windows") def test_last_test_not_overriden_by_stop_on_error(links_dir, suite): failed_test = suite[4] failed_test.when_run.fail() @@ -192,7 +193,7 @@ def test_result_log_links(files_dir, session): assert result.get_log_path() is not None assert result.get_log_path().startswith(str(files_dir)) - +@pytest.mark.skipif(sys.platform == 'win32', reason="does not run on windows") def test_last_failed(suite, links_dir): suite[-5].when_run.fail() last_failed = suite[-2] @@ -216,6 +217,7 @@ def test_errors_log_for_test(suite, suite_test, errors_log_path, logs_dir): lines = f.read().splitlines() assert error_line in lines +@pytest.mark.skipif(sys.platform == 'win32', reason="does not run on windows") @pytest.mark.parametrize('should_keep_failed_tests', [True, False]) def test_logs_deletion(suite, suite_test, errors_log_path, logs_dir, config_override, should_keep_failed_tests): config_override('log.cleanup.enabled', True) diff --git a/tests/test_parallel.py b/tests/test_parallel.py index 8ce3b286..bf418979 100644 --- a/tests/test_parallel.py +++ b/tests/test_parallel.py @@ -1,6 +1,8 @@ import slash import os import signal +import sys + from .utils.suite_writer import Suite from slash.resuming import get_tests_from_previous_session from slash.exceptions import InteractiveParallelNotAllowed, ParallelTimeout @@ -12,6 +14,9 @@ import tempfile import pytest +if sys.platform.startswith("win"): + pytest.skip("does not run on windows", allow_module_level=True) + @pytest.fixture(scope='module', autouse=True) def no_parallel_user_config(request): tmpdir = tempfile.mkdtemp() diff --git a/tests/test_site_customization.py b/tests/test_site_customization.py index 71c1d04c..23abefca 100644 --- a/tests/test_site_customization.py +++ b/tests/test_site_customization.py @@ -61,8 +61,9 @@ def _test_customize_via_local_slashrc(self, also_use_global): with open(global_slashrc_path, "w") as f: f.write(self.get_customization_source()) + new_path = self.get_new_path() self.addCleanup(os.chdir, os.path.abspath(".")) - os.chdir(self.get_new_path()) + os.chdir(new_path) with open(".slashrc", "w") as f: f.write(self.get_customization_source()) self.assert_customization_loaded() diff --git a/tests/test_test_loading.py b/tests/test_test_loading.py index 1c6d6b5a..34bd638c 100644 --- a/tests/test_test_loading.py +++ b/tests/test_test_loading.py @@ -54,7 +54,7 @@ def test_dir(tmpdir, names, indices): @pytest.fixture def names(): - return ['a/test_a_b.py', 'a/test_b_a.py', 'b/test_a_a.py', 'b/test_a_b.py'] + return [os.path.normpath(p) for p in ['a/test_a_b.py', 'a/test_b_a.py', 'b/test_a_a.py', 'b/test_a_b.py']] def _sorted_by_indices(items, indices): returned = [None for _ in items] diff --git a/tests/test_warnings.py b/tests/test_warnings.py index dd3ff4ec..f0f80cdc 100644 --- a/tests/test_warnings.py +++ b/tests/test_warnings.py @@ -1,4 +1,5 @@ # pylint: disable=unused-variable,redefined-outer-name +import os import collections import warnings from contextlib import contextmanager @@ -44,7 +45,7 @@ def warning_added(warning): assert isinstance(w.filename, str) assert w.lineno assert w.filename - assert w.filename.rsplit('/', 1)[-1] == suite_test.file.get_relative_path() + assert w.filename.rsplit(os.path.sep, 1)[-1] == suite_test.file.get_relative_path() warning_type = w.details['type'] assert isinstance(warning_type, str) assert warning_type == 'LogbookWarning' diff --git a/tests/test_xunit_plugin.py b/tests/test_xunit_plugin.py index 1af5b7dd..ccbb2f26 100644 --- a/tests/test_xunit_plugin.py +++ b/tests/test_xunit_plugin.py @@ -1,5 +1,6 @@ # pylint: disable=redefined-outer-name import os +import sys import pytest @@ -129,6 +130,7 @@ def func(test): return func +@pytest.mark.skipif(sys.platform == 'win32', reason="does not run on windows") @pytest.mark.parametrize('action', ['skipped', 'error', 'failure', 'success']) def test_xunit_parallel_suite(parallel_suite, xunit_filename, action): test = parallel_suite[3]