-
Notifications
You must be signed in to change notification settings - Fork 9
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
tasks: added --pytest-args to tests #100
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,9 @@ def build_docs(c): | |
def linters(c, color=False): | ||
"""Run code linters""" | ||
run(f"flake8 --color {'always' if color else 'never'} tests valkey") | ||
run(f"black {'--color' if color else ''} --target-version py37 --check --diff tests valkey") | ||
run( | ||
f"black {'--color' if color else ''} --target-version py37 --check --diff tests valkey" | ||
) | ||
run(f"isort {'--color' if color else ''} --check-only --diff tests valkey") | ||
run("vulture valkey whitelist.py --min-confidence 80") | ||
run("flynt --fail-on-change --dry-run tests valkey") | ||
|
@@ -42,40 +44,43 @@ def all_tests(c, color=False): | |
|
||
|
||
@task | ||
def tests(c, uvloop=False, protocol=2, color=False): | ||
def tests(c, uvloop=False, protocol=2, color=False, pytest_args=None): | ||
"""Run the valkey-py test suite against the current python, | ||
with and without libvalkey. | ||
""" | ||
print("Starting Valkey tests") | ||
print("pytest_args:", pytest_args) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By default this will print "pytest_args: None" which could be misleading as we pass a lot of arguments to pytest. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is actually a leftover that I forgot to remove. Would you rather see it removed or having an additional proper message about pytest args? |
||
standalone_tests(c, uvloop=uvloop, protocol=protocol, color=color) | ||
cluster_tests(c, uvloop=uvloop, protocol=protocol, color=color) | ||
|
||
|
||
@task | ||
def standalone_tests(c, uvloop=False, protocol=2, color=False): | ||
def standalone_tests(c, uvloop=False, protocol=2, color=False, pytest_args=None): | ||
"""Run tests against a standalone valkey instance""" | ||
color_arg = f"--color={'yes' if color else 'no'}" | ||
shared_args = f"{color_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_valkey.xml -W always -m 'not onlycluster'" | ||
pytest_args = pytest_args or "" | ||
if uvloop: | ||
run( | ||
f"pytest --color={'yes' if color else 'no'} --protocol={protocol} --cov=./ --cov-report=xml:coverage_valkey.xml -W always -m 'not onlycluster' --uvloop --junit-xml=standalone-uvloop-results.xml" | ||
f"pytest {shared_args} --uvloop --junit-xml=standalone-uvloop-results.xml {pytest_args}" | ||
) | ||
else: | ||
run( | ||
f"pytest --color={'yes' if color else 'no'} --protocol={protocol} --cov=./ --cov-report=xml:coverage_valkey.xml -W always -m 'not onlycluster' --junit-xml=standalone-results.xml" | ||
) | ||
run(f"pytest {shared_args} --junit-xml=standalone-results.xml {pytest_args}") | ||
|
||
|
||
@task | ||
def cluster_tests(c, uvloop=False, protocol=2, color=False): | ||
def cluster_tests(c, uvloop=False, protocol=2, color=False, pytest_args=None): | ||
"""Run tests against a valkey cluster""" | ||
cluster_url = "valkey://localhost:16379/0" | ||
color_arg = f"--color={'yes' if color else 'no'}" | ||
shared_args = f"{color_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_cluster.xml -W always -m 'not onlynoncluster and not valkeymod' --valkey-url={cluster_url}" | ||
pytest_args = pytest_args or "" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we somehow try to validate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can do this, yes. This approach leaves it to user's discretion. After all, any arguments they would pass they would run on their machine :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I mean is that this argument seem to be not easy to use, but it's easy to misuse. |
||
if uvloop: | ||
run( | ||
f"pytest --color={'yes' if color else 'no'} --protocol={protocol} --cov=./ --cov-report=xml:coverage_cluster.xml -W always -m 'not onlynoncluster and not valkeymod' --valkey-url={cluster_url} --junit-xml=cluster-uvloop-results.xml --uvloop" | ||
f"pytest {shared_args} --junit-xml=cluster-uvloop-results.xml --uvloop {pytest_args}" | ||
) | ||
else: | ||
run( | ||
f"pytest --color={'yes' if color else 'no'} --protocol={protocol} --cov=./ --cov-report=xml:coverage_clusteclient.xml -W always -m 'not onlynoncluster and not valkeymod' --valkey-url={cluster_url} --junit-xml=cluster-results.xml" | ||
) | ||
run(f"pytest {shared_args} --junit-xml=cluster-results.xml {pytest_args}") | ||
|
||
|
||
@task | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I missing something or is this just a formatting change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah autoformatting changed this line for me :/ Do you want me to move it to a separate commit?