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

BUG: fix coverage #7

Closed
ThibTrip opened this issue Apr 6, 2020 · 0 comments
Closed

BUG: fix coverage #7

ThibTrip opened this issue Apr 6, 2020 · 0 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@ThibTrip
Copy link
Owner

ThibTrip commented Apr 6, 2020

Coverage does not work as expected because we need to do one pytest and not 3. We could parameterize with multiple engines by changing the pytest command to:

pytest -s -v pangres --cov=./pangres --sqlite_conn=$sqlite_conn --pg_conn=$pg_conn --mysql_conn=$mysql_conn

However the order is not how it should be for our tests:

test_1[engine0,schema]
test_1[engine1,schema]
test_2[engine0,schema]
test_2[engine1,schema]
Should be:
test_1[engine0,schema]
test_2[engine0,schema]
test_1[engine1,schema]
test_2[engine1,schema]

I will try to fix this with classes as proposed here: https://stackoverflow.com/a/31966811/10551772

Not sure how to do this but I'll try. If anyone wants to give me a quick example so I can reproduce it on all tests that would be appreciated 👍 !

I think the configuration I locally updated in conftest.py is correct (see below) so we just have to change the tests.

def pytest_addoption(parser):
    parser.addoption('--sqlite_conn', action="store")
    parser.addoption('--pg_conn', action="store")
    parser.addoption('--mysql_conn', action="store")
    parser.addoption('--pg_schema', action='store', default=None)


def pytest_generate_tests(metafunc):
    # This is called for every test. Only get/set command line arguments
    # if the argument is specified in the list of test "fixturenames".
    conn_strings = {'sqlite':metafunc.config.option.sqlite_conn,
                    'pg':metafunc.config.option.pg_conn,
                    'mysql':metafunc.config.option.mysql_conn}
    engines = []
    schemas = []
    for db_type, conn_string in conn_strings.items():
        schema = metafunc.config.option.pg_schema if db_type == 'pg' else None
        engine = create_engine(conn_string)
        schemas.append(schema)
        engines.append(engine)
    metafunc.parametrize("engine", engines)
    metafunc.parametrize("schema", schemas)
@ThibTrip ThibTrip self-assigned this Apr 6, 2020
@ThibTrip ThibTrip added help wanted Extra attention is needed bug Something isn't working labels Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant