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

Implementing no_cov feature for #131 #135

Merged
merged 3 commits into from Oct 9, 2016

Conversation

Projects
None yet
2 participants
@kozmaz87
Contributor

kozmaz87 commented Oct 4, 2016

Please let me know what you think.

if self._disabled:
markup = {'red': True, 'bold': True}
msg = (
'WARNING: Coverage disabled by user!'

This comment has been minimized.

@ionelmc

ionelmc Oct 4, 2016

Member

I can only assume that you make this extra cruft here to make a longer message and use the pytest's warn system (in addition to writing to terminalreporter, of course)?

If so, you can use something like terminalreporter.config.warn(code='COV-U1', message=msg).

Also, I would mention "--no-cov" somehow in the warning message, just to be clear about what's going on.

This comment has been minimized.

@kozmaz87

kozmaz87 Oct 4, 2016

Contributor

I just copied from elsewhere in the file. It uses the same technique. I was consistent with its style

This comment has been minimized.

@ionelmc

ionelmc Oct 4, 2016

Member

Ah yes, you're right. Still, I think it's good if we'd use the config.warn thing here ...

This comment has been minimized.

@kozmaz87

kozmaz87 Oct 4, 2016

Contributor

Also the reason for not mentioning the no-cov flag in there is precisely to avoid spaghetti coding. You would constantly have to maintain this line whenever you decide to rename this variable. Unfortunate enough already that I have to copy it in the README.rst I know that Ctrl+R exists but some ppl. prefer typing. Not to mention --no-cov vs. no_cov. By all means I will make the changes but wanted you to know the reason just for the record.

This comment has been minimized.

@ionelmc

ionelmc Oct 4, 2016

Member

I'm pretty sure we can grep/sed for --no-cov if we ever decide to rename 😀

This comment has been minimized.

@kozmaz87

kozmaz87 Oct 4, 2016

Contributor

This is for the test

This comment has been minimized.

@kozmaz87

kozmaz87 Oct 5, 2016

Contributor

How can I test this? Now the log line is simply not there in the stderr/stdout?

This comment has been minimized.

@ionelmc

ionelmc Oct 5, 2016

Member

I would send that message both to the warner and terminalwriter.

To test the warning you need to configure pytest to show warnings (add -rw to commandline).

This comment has been minimized.

@kozmaz87

kozmaz87 Oct 5, 2016

Contributor

Why would you duplicate the message? Also it writes on the console for me if I run py.test without any flags but the test framework does not pick those lines up. Just

     assert 'WCOV-U1 None Coverage disabled via --no-cov switch!' in  result.stdout.str()
E   assert 'WCOV-U1 None Coverage disabled via --no-cov switch!' in '============================= test session starts ==============================\nplatform darwin -- Python 2.6.8 -- p...D\ntest_no_cov.py::test_foo[9] PASSED\n\n==================== 10 passed, 1 warnings in 0.02 seconds ====================='
E    +  where '============================= test session starts ==============================\nplatform darwin -- Python 2.6.8 -- p...D\ntest_no_cov.py::test_foo[9] PASSED\n\n==================== 10 passed, 1 warnings in 0.02 seconds =====================' = <bound method LineMatcher.str of <_pytest.pytester.LineMatcher instance at 0x1050df248>>()

This comment has been minimized.

@kozmaz87

kozmaz87 Oct 5, 2016

Contributor

Adding the -rw flag to the test does not help

kozmaz87 added some commits Oct 4, 2016

@ionelmc ionelmc merged commit c6478ce into pytest-dev:master Oct 9, 2016

1 check failed

continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details
@ionelmc

This comment has been minimized.

Member

ionelmc commented Oct 10, 2016

Merged and released v2.4.0, thanks!

jsonn pushed a commit to jsonn/pkgsrc that referenced this pull request Oct 19, 2016

wiz
Updated py-test-cov to 2.4.0.
2.4.0 (2016-10-10)
------------------

* Added a "disarm" option: ``--no-cov``. It will disable coverage measurements. Contributed by Zoltan Kozma in
  `PR#135 <https://github.com/pytest-dev/pytest-cov/pull/135>`_.

  **WARNING: Do not put this in your configuration files, it's meant to be an one-off for situations where you want to
  disable coverage from command line.**
* Fixed broken exception handling on ``.pth`` file. See `#136 <https://github.com/pytest-dev/pytest-cov/issues/136>`_.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment