Skip to content

Can't get conditional pragmas to work #179

Closed
@dosaki

Description

@dosaki

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions