Avoid printing of dots












1














I run pytest with option -q.



Unfortunately this prints out a lot of dots. Example:



...................................................................................s...............s...................................ssssss..................................................................................................................................s..............s.........................s..............................................................................................................F....s.s............s.....................s...........................................................................................................................
=================================== FAILURES ===================================
_____________________ TestFoo.test_bar _____________________
Traceback (most recent call last):
(cut)


Is there a way to avoid this long list of dots and "s" characters?



Update



There is a valid answer. But somehow it is too long for me. I use this workaround now:I added this to the script which calls pytest: pytest -q | perl -pe 's/^[.sxFE]{20,}$//g'










share|improve this question





























    1














    I run pytest with option -q.



    Unfortunately this prints out a lot of dots. Example:



    ...................................................................................s...............s...................................ssssss..................................................................................................................................s..............s.........................s..............................................................................................................F....s.s............s.....................s...........................................................................................................................
    =================================== FAILURES ===================================
    _____________________ TestFoo.test_bar _____________________
    Traceback (most recent call last):
    (cut)


    Is there a way to avoid this long list of dots and "s" characters?



    Update



    There is a valid answer. But somehow it is too long for me. I use this workaround now:I added this to the script which calls pytest: pytest -q | perl -pe 's/^[.sxFE]{20,}$//g'










    share|improve this question



























      1












      1








      1







      I run pytest with option -q.



      Unfortunately this prints out a lot of dots. Example:



      ...................................................................................s...............s...................................ssssss..................................................................................................................................s..............s.........................s..............................................................................................................F....s.s............s.....................s...........................................................................................................................
      =================================== FAILURES ===================================
      _____________________ TestFoo.test_bar _____________________
      Traceback (most recent call last):
      (cut)


      Is there a way to avoid this long list of dots and "s" characters?



      Update



      There is a valid answer. But somehow it is too long for me. I use this workaround now:I added this to the script which calls pytest: pytest -q | perl -pe 's/^[.sxFE]{20,}$//g'










      share|improve this question















      I run pytest with option -q.



      Unfortunately this prints out a lot of dots. Example:



      ...................................................................................s...............s...................................ssssss..................................................................................................................................s..............s.........................s..............................................................................................................F....s.s............s.....................s...........................................................................................................................
      =================================== FAILURES ===================================
      _____________________ TestFoo.test_bar _____________________
      Traceback (most recent call last):
      (cut)


      Is there a way to avoid this long list of dots and "s" characters?



      Update



      There is a valid answer. But somehow it is too long for me. I use this workaround now:I added this to the script which calls pytest: pytest -q | perl -pe 's/^[.sxFE]{20,}$//g'







      python pytest






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 26 '18 at 15:24

























      asked Nov 19 '18 at 12:22









      guettli

      3,22120128268




      3,22120128268
























          1 Answer
          1






          active

          oldest

          votes


















          3














          The verbosity options can't turn off the test outcome printing. However, pytest can be customized in many ways, including the outcome printing. To change this, you would override the pytest_report_teststatus hook.



          turn off short letters



          Create a file conftest.py with the following content:



          import pytest

          def pytest_report_teststatus(report):
          category, short, verbose = '', '', ''
          if hasattr(report, 'wasxfail'):
          if report.skipped:
          category = 'xfailed'
          verbose = 'xfail'
          elif report.passed:
          category = 'xpassed'
          verbose = ('XPASS', {'yellow': True})
          return (category, short, verbose)
          elif report.when in ('setup', 'teardown'):
          if report.failed:
          category = 'error'
          verbose = 'ERROR'
          elif report.skipped:
          category = 'skipped'
          verbose = 'SKIPPED'
          return (category, short, verbose)
          category = report.outcome
          verbose = category.upper()
          return (category, short, verbose)


          Now running the tests will not print any short outcome letters (.sxFE). The code is a bit verbose, but handles all the standard outcomes defined in the framework.



          turn off verbose outcomes



          When running in verbose mode, pytest prints the outcome along with the test case name:



          $ pytest -sv
          =================================== test session starts ===================================
          ...
          test_spam.py::test_spam PASSED
          test_spam.py::test_eggs FAILED
          test_spam.py::test_bacon SKIPPED
          test_spam.py::test_foo xfail
          ...


          If you remove the lines setting verbose from the above hook impl (leaving it set to an empty string), pytest will also stop printing outcomes in verbose mode:



          import pytest

          def pytest_report_teststatus(report):
          category, short, verbose = '', '', ''
          if hasattr(report, 'wasxfail'):
          if report.skipped:
          category = 'xfailed'
          elif report.passed:
          category = 'xpassed'
          return (category, short, verbose)
          elif report.when in ('setup', 'teardown'):
          if report.failed:
          category = 'error'
          elif report.skipped:
          category = 'skipped'
          return (category, short, verbose)
          category = report.outcome
          return (category, short, verbose)


          $ pytest -sv
          =================================== test session starts ===================================
          ...
          test_spam.py::test_spam
          test_spam.py::test_eggs
          test_spam.py::test_bacon
          test_spam.py::test_foo
          ...


          introducing custom reporting mode via command line switch



          The below example will turn off printing both short and verbose outcomes when --silent flag is passed from command line:



          import pytest

          def pytest_addoption(parser):
          parser.addoption('--silent', action='store_true', default=False)


          def pytest_report_teststatus(report):
          category, short, verbose = '', '', ''
          if not pytest.config.getoption('--silent'):
          return None

          if hasattr(report, 'wasxfail'):
          if report.skipped:
          category = 'xfailed'
          elif report.passed:
          category = 'xpassed'
          return (category, short, verbose)
          elif report.when in ('setup', 'teardown'):
          if report.failed:
          category = 'error'
          elif report.skipped:
          category = 'skipped'
          return (category, short, verbose)
          category = report.outcome
          return (category, short, verbose)





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374551%2favoid-printing-of-dots%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            3














            The verbosity options can't turn off the test outcome printing. However, pytest can be customized in many ways, including the outcome printing. To change this, you would override the pytest_report_teststatus hook.



            turn off short letters



            Create a file conftest.py with the following content:



            import pytest

            def pytest_report_teststatus(report):
            category, short, verbose = '', '', ''
            if hasattr(report, 'wasxfail'):
            if report.skipped:
            category = 'xfailed'
            verbose = 'xfail'
            elif report.passed:
            category = 'xpassed'
            verbose = ('XPASS', {'yellow': True})
            return (category, short, verbose)
            elif report.when in ('setup', 'teardown'):
            if report.failed:
            category = 'error'
            verbose = 'ERROR'
            elif report.skipped:
            category = 'skipped'
            verbose = 'SKIPPED'
            return (category, short, verbose)
            category = report.outcome
            verbose = category.upper()
            return (category, short, verbose)


            Now running the tests will not print any short outcome letters (.sxFE). The code is a bit verbose, but handles all the standard outcomes defined in the framework.



            turn off verbose outcomes



            When running in verbose mode, pytest prints the outcome along with the test case name:



            $ pytest -sv
            =================================== test session starts ===================================
            ...
            test_spam.py::test_spam PASSED
            test_spam.py::test_eggs FAILED
            test_spam.py::test_bacon SKIPPED
            test_spam.py::test_foo xfail
            ...


            If you remove the lines setting verbose from the above hook impl (leaving it set to an empty string), pytest will also stop printing outcomes in verbose mode:



            import pytest

            def pytest_report_teststatus(report):
            category, short, verbose = '', '', ''
            if hasattr(report, 'wasxfail'):
            if report.skipped:
            category = 'xfailed'
            elif report.passed:
            category = 'xpassed'
            return (category, short, verbose)
            elif report.when in ('setup', 'teardown'):
            if report.failed:
            category = 'error'
            elif report.skipped:
            category = 'skipped'
            return (category, short, verbose)
            category = report.outcome
            return (category, short, verbose)


            $ pytest -sv
            =================================== test session starts ===================================
            ...
            test_spam.py::test_spam
            test_spam.py::test_eggs
            test_spam.py::test_bacon
            test_spam.py::test_foo
            ...


            introducing custom reporting mode via command line switch



            The below example will turn off printing both short and verbose outcomes when --silent flag is passed from command line:



            import pytest

            def pytest_addoption(parser):
            parser.addoption('--silent', action='store_true', default=False)


            def pytest_report_teststatus(report):
            category, short, verbose = '', '', ''
            if not pytest.config.getoption('--silent'):
            return None

            if hasattr(report, 'wasxfail'):
            if report.skipped:
            category = 'xfailed'
            elif report.passed:
            category = 'xpassed'
            return (category, short, verbose)
            elif report.when in ('setup', 'teardown'):
            if report.failed:
            category = 'error'
            elif report.skipped:
            category = 'skipped'
            return (category, short, verbose)
            category = report.outcome
            return (category, short, verbose)





            share|improve this answer




























              3














              The verbosity options can't turn off the test outcome printing. However, pytest can be customized in many ways, including the outcome printing. To change this, you would override the pytest_report_teststatus hook.



              turn off short letters



              Create a file conftest.py with the following content:



              import pytest

              def pytest_report_teststatus(report):
              category, short, verbose = '', '', ''
              if hasattr(report, 'wasxfail'):
              if report.skipped:
              category = 'xfailed'
              verbose = 'xfail'
              elif report.passed:
              category = 'xpassed'
              verbose = ('XPASS', {'yellow': True})
              return (category, short, verbose)
              elif report.when in ('setup', 'teardown'):
              if report.failed:
              category = 'error'
              verbose = 'ERROR'
              elif report.skipped:
              category = 'skipped'
              verbose = 'SKIPPED'
              return (category, short, verbose)
              category = report.outcome
              verbose = category.upper()
              return (category, short, verbose)


              Now running the tests will not print any short outcome letters (.sxFE). The code is a bit verbose, but handles all the standard outcomes defined in the framework.



              turn off verbose outcomes



              When running in verbose mode, pytest prints the outcome along with the test case name:



              $ pytest -sv
              =================================== test session starts ===================================
              ...
              test_spam.py::test_spam PASSED
              test_spam.py::test_eggs FAILED
              test_spam.py::test_bacon SKIPPED
              test_spam.py::test_foo xfail
              ...


              If you remove the lines setting verbose from the above hook impl (leaving it set to an empty string), pytest will also stop printing outcomes in verbose mode:



              import pytest

              def pytest_report_teststatus(report):
              category, short, verbose = '', '', ''
              if hasattr(report, 'wasxfail'):
              if report.skipped:
              category = 'xfailed'
              elif report.passed:
              category = 'xpassed'
              return (category, short, verbose)
              elif report.when in ('setup', 'teardown'):
              if report.failed:
              category = 'error'
              elif report.skipped:
              category = 'skipped'
              return (category, short, verbose)
              category = report.outcome
              return (category, short, verbose)


              $ pytest -sv
              =================================== test session starts ===================================
              ...
              test_spam.py::test_spam
              test_spam.py::test_eggs
              test_spam.py::test_bacon
              test_spam.py::test_foo
              ...


              introducing custom reporting mode via command line switch



              The below example will turn off printing both short and verbose outcomes when --silent flag is passed from command line:



              import pytest

              def pytest_addoption(parser):
              parser.addoption('--silent', action='store_true', default=False)


              def pytest_report_teststatus(report):
              category, short, verbose = '', '', ''
              if not pytest.config.getoption('--silent'):
              return None

              if hasattr(report, 'wasxfail'):
              if report.skipped:
              category = 'xfailed'
              elif report.passed:
              category = 'xpassed'
              return (category, short, verbose)
              elif report.when in ('setup', 'teardown'):
              if report.failed:
              category = 'error'
              elif report.skipped:
              category = 'skipped'
              return (category, short, verbose)
              category = report.outcome
              return (category, short, verbose)





              share|improve this answer


























                3












                3








                3






                The verbosity options can't turn off the test outcome printing. However, pytest can be customized in many ways, including the outcome printing. To change this, you would override the pytest_report_teststatus hook.



                turn off short letters



                Create a file conftest.py with the following content:



                import pytest

                def pytest_report_teststatus(report):
                category, short, verbose = '', '', ''
                if hasattr(report, 'wasxfail'):
                if report.skipped:
                category = 'xfailed'
                verbose = 'xfail'
                elif report.passed:
                category = 'xpassed'
                verbose = ('XPASS', {'yellow': True})
                return (category, short, verbose)
                elif report.when in ('setup', 'teardown'):
                if report.failed:
                category = 'error'
                verbose = 'ERROR'
                elif report.skipped:
                category = 'skipped'
                verbose = 'SKIPPED'
                return (category, short, verbose)
                category = report.outcome
                verbose = category.upper()
                return (category, short, verbose)


                Now running the tests will not print any short outcome letters (.sxFE). The code is a bit verbose, but handles all the standard outcomes defined in the framework.



                turn off verbose outcomes



                When running in verbose mode, pytest prints the outcome along with the test case name:



                $ pytest -sv
                =================================== test session starts ===================================
                ...
                test_spam.py::test_spam PASSED
                test_spam.py::test_eggs FAILED
                test_spam.py::test_bacon SKIPPED
                test_spam.py::test_foo xfail
                ...


                If you remove the lines setting verbose from the above hook impl (leaving it set to an empty string), pytest will also stop printing outcomes in verbose mode:



                import pytest

                def pytest_report_teststatus(report):
                category, short, verbose = '', '', ''
                if hasattr(report, 'wasxfail'):
                if report.skipped:
                category = 'xfailed'
                elif report.passed:
                category = 'xpassed'
                return (category, short, verbose)
                elif report.when in ('setup', 'teardown'):
                if report.failed:
                category = 'error'
                elif report.skipped:
                category = 'skipped'
                return (category, short, verbose)
                category = report.outcome
                return (category, short, verbose)


                $ pytest -sv
                =================================== test session starts ===================================
                ...
                test_spam.py::test_spam
                test_spam.py::test_eggs
                test_spam.py::test_bacon
                test_spam.py::test_foo
                ...


                introducing custom reporting mode via command line switch



                The below example will turn off printing both short and verbose outcomes when --silent flag is passed from command line:



                import pytest

                def pytest_addoption(parser):
                parser.addoption('--silent', action='store_true', default=False)


                def pytest_report_teststatus(report):
                category, short, verbose = '', '', ''
                if not pytest.config.getoption('--silent'):
                return None

                if hasattr(report, 'wasxfail'):
                if report.skipped:
                category = 'xfailed'
                elif report.passed:
                category = 'xpassed'
                return (category, short, verbose)
                elif report.when in ('setup', 'teardown'):
                if report.failed:
                category = 'error'
                elif report.skipped:
                category = 'skipped'
                return (category, short, verbose)
                category = report.outcome
                return (category, short, verbose)





                share|improve this answer














                The verbosity options can't turn off the test outcome printing. However, pytest can be customized in many ways, including the outcome printing. To change this, you would override the pytest_report_teststatus hook.



                turn off short letters



                Create a file conftest.py with the following content:



                import pytest

                def pytest_report_teststatus(report):
                category, short, verbose = '', '', ''
                if hasattr(report, 'wasxfail'):
                if report.skipped:
                category = 'xfailed'
                verbose = 'xfail'
                elif report.passed:
                category = 'xpassed'
                verbose = ('XPASS', {'yellow': True})
                return (category, short, verbose)
                elif report.when in ('setup', 'teardown'):
                if report.failed:
                category = 'error'
                verbose = 'ERROR'
                elif report.skipped:
                category = 'skipped'
                verbose = 'SKIPPED'
                return (category, short, verbose)
                category = report.outcome
                verbose = category.upper()
                return (category, short, verbose)


                Now running the tests will not print any short outcome letters (.sxFE). The code is a bit verbose, but handles all the standard outcomes defined in the framework.



                turn off verbose outcomes



                When running in verbose mode, pytest prints the outcome along with the test case name:



                $ pytest -sv
                =================================== test session starts ===================================
                ...
                test_spam.py::test_spam PASSED
                test_spam.py::test_eggs FAILED
                test_spam.py::test_bacon SKIPPED
                test_spam.py::test_foo xfail
                ...


                If you remove the lines setting verbose from the above hook impl (leaving it set to an empty string), pytest will also stop printing outcomes in verbose mode:



                import pytest

                def pytest_report_teststatus(report):
                category, short, verbose = '', '', ''
                if hasattr(report, 'wasxfail'):
                if report.skipped:
                category = 'xfailed'
                elif report.passed:
                category = 'xpassed'
                return (category, short, verbose)
                elif report.when in ('setup', 'teardown'):
                if report.failed:
                category = 'error'
                elif report.skipped:
                category = 'skipped'
                return (category, short, verbose)
                category = report.outcome
                return (category, short, verbose)


                $ pytest -sv
                =================================== test session starts ===================================
                ...
                test_spam.py::test_spam
                test_spam.py::test_eggs
                test_spam.py::test_bacon
                test_spam.py::test_foo
                ...


                introducing custom reporting mode via command line switch



                The below example will turn off printing both short and verbose outcomes when --silent flag is passed from command line:



                import pytest

                def pytest_addoption(parser):
                parser.addoption('--silent', action='store_true', default=False)


                def pytest_report_teststatus(report):
                category, short, verbose = '', '', ''
                if not pytest.config.getoption('--silent'):
                return None

                if hasattr(report, 'wasxfail'):
                if report.skipped:
                category = 'xfailed'
                elif report.passed:
                category = 'xpassed'
                return (category, short, verbose)
                elif report.when in ('setup', 'teardown'):
                if report.failed:
                category = 'error'
                elif report.skipped:
                category = 'skipped'
                return (category, short, verbose)
                category = report.outcome
                return (category, short, verbose)






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 19 '18 at 22:16

























                answered Nov 19 '18 at 22:08









                hoefling

                11.6k42759




                11.6k42759






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374551%2favoid-printing-of-dots%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    MongoDB - Not Authorized To Execute Command

                    in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

                    Npm cannot find a required file even through it is in the searched directory