From 77ed0ed46c429315aef5dbd190f6f29a2aa4b9f5 Mon Sep 17 00:00:00 2001 From: Stuart Young Date: Tue, 31 Oct 2017 14:30:07 -0400 Subject: [PATCH] add option to disable capturing stderr in pytest --- pavelib/tests.py | 8 ++++++++ pavelib/utils/test/suites/pytest_suite.py | 6 ++++++ scripts/generic-ci-tests.sh | 10 +++++----- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/pavelib/tests.py b/pavelib/tests.py index fa0bacb915..330cbe4b9c 100644 --- a/pavelib/tests.py +++ b/pavelib/tests.py @@ -49,6 +49,10 @@ __test__ = False # do not collect make_option("--verbose", action="store_const", const=2, dest="verbosity"), make_option("-q", "--quiet", action="store_const", const=0, dest="verbosity"), make_option("-v", "--verbosity", action="count", dest="verbosity", default=1), + make_option( + "--disable_capture", action="store_true", dest="disable_capture", + help="Disable capturing of stdout/stderr" + ), make_option( '--disable-migrations', action='store_true', @@ -132,6 +136,10 @@ def test_system(options, passthrough_options): make_option("--verbose", action="store_const", const=2, dest="verbosity"), make_option("-q", "--quiet", action="store_const", const=0, dest="verbosity"), make_option("-v", "--verbosity", action="count", dest="verbosity", default=1), + make_option( + "--disable_capture", action="store_true", dest="disable_capture", + help="Disable capturing of stdout/stderr" + ), ], share_with=['pavelib.utils.test.utils.clean_reports_dir']) @PassthroughTask @timed diff --git a/pavelib/utils/test/suites/pytest_suite.py b/pavelib/utils/test/suites/pytest_suite.py index 1f3b4ce0b7..7d48ace091 100644 --- a/pavelib/utils/test/suites/pytest_suite.py +++ b/pavelib/utils/test/suites/pytest_suite.py @@ -32,6 +32,7 @@ class PytestSuite(TestSuite): self.django_toxenv = 'py27-django111' else: self.django_toxenv = 'py27-django18' + self.disable_capture = kwargs.get('disable_capture', None) self.report_dir = Env.REPORT_DIR / self.root # If set, put reports for run in "unique" directories. @@ -144,6 +145,9 @@ class SystemTestSuite(PytestSuite): elif self.verbosity > 1: cmd.append("--verbose") + if self.disable_capture: + cmd.append("-s") + if self.processes == -1: cmd.append('-n auto') cmd.append('--dist=loadscope') @@ -230,6 +234,8 @@ class LibTestSuite(PytestSuite): cmd.append("--quiet") elif self.verbosity > 1: cmd.append("--verbose") + if self.disable_capture: + cmd.append("-s") cmd.append(self.test_id) return self._under_coverage_cmd(cmd) diff --git a/scripts/generic-ci-tests.sh b/scripts/generic-ci-tests.sh index 3fe88b844c..acd656e9e2 100755 --- a/scripts/generic-ci-tests.sh +++ b/scripts/generic-ci-tests.sh @@ -111,13 +111,13 @@ case "$TEST_SUITE" in "lms-unit") case "$SHARD" in "all") - paver test_system -s lms $PAVER_ARGS $PARALLEL 2> lms-tests.log + paver test_system -s lms --disable_capture $PAVER_ARGS $PARALLEL 2> lms-tests.log ;; [1-3]) - paver test_system -s lms --eval-attr="shard==$SHARD" $PAVER_ARGS $PARALLEL 2> lms-tests.$SHARD.log + paver test_system -s lms --disable_capture --eval-attr="shard==$SHARD" $PAVER_ARGS $PARALLEL 2> lms-tests.$SHARD.log ;; 4|"noshard") - paver test_system -s lms --eval-attr='not shard' $PAVER_ARGS $PARALLEL 2> lms-tests.4.log + paver test_system -s lms --disable_capture --eval-attr='not shard' $PAVER_ARGS $PARALLEL 2> lms-tests.4.log ;; *) # If no shard is specified, rather than running all tests, create an empty xunit file. This is a @@ -131,11 +131,11 @@ case "$TEST_SUITE" in ;; "cms-unit") - paver test_system -s cms $PAVER_ARGS 2> cms-tests.log + paver test_system -s cms --disable_capture $PAVER_ARGS 2> cms-tests.log ;; "commonlib-unit") - paver test_lib $PAVER_ARGS 2> common-tests.log + paver test_lib --disable_capture $PAVER_ARGS 2> common-tests.log ;; "js-unit")