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

Can't get conditional pragmas to work #179

Closed
dosaki opened this issue Sep 26, 2022 · 3 comments
Closed

Can't get conditional pragmas to work #179

dosaki opened this issue Sep 26, 2022 · 3 comments

Comments

@dosaki
Copy link

dosaki commented Sep 26, 2022

I'm trying to work around #178 by running the tests by manually setting an IS_INTEGRATION variable.

This is my .coveragerc set up:

[run]
omit = *entrypoint*,*/tests/*

[coverage:run]
plugins =
  coverage_conditional_plugin

[coverage:report]
skip_empty = true
omit = *entrypoint*,*/tests/*

[coverage:coverage_conditional_plugin]
rules =
  "os_environ['IS_INTEGRATION'].lower()=='true'": integration
  "os_environ['IS_INTEGRATION'].lower()=='false'": unit

And this is how I've annotated some methods:

    @classmethod
    def get(cls, value, joins=[]):  # pragma: integration
        primary_keys = cls.get_primary_key_names()
        if not primary_keys or len(primary_keys) < 1:
            return None

        result = cls.find_all_by(primary_keys[0], value, joins)
        try:
            return result[0]
        except:
            return None

However, when running with IS_INTEGRATION='false', the method above is still flagged as uncovered:
Screenshot 2022-09-26 at 11 16 30

@sobolevn
Copy link
Member

sobolevn commented Sep 26, 2022

Try switching unit and integration. Will it work?

The reason is that pragma: some means pragma: no cover if some

@dosaki
Copy link
Author

dosaki commented Sep 26, 2022

That makes sense! I guess I got confused reading the docs.
Thanks ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants