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

Issue #402: Fix tests that fail as a result of running pytest with no flags #404

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pyani/scripts/average_nucleotide_identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,11 @@ def process_arguments(args: Optional[Namespace]) -> Namespace:
shows the version and exits.
"""
# Catch execution with no arguments
if len(sys.argv) == 1:
# But only for the `average_nucleotide_identity.py` executable (`pytest` was also being caught here)
if (
len(sys.argv) == 1
and Path(sys.argv[0]).name == "average_nucleotide_identity.py"
):
sys.stderr.write("pyani version: {0}\n".format(__version__))
raise SystemExit(0)

Expand Down
7 changes: 6 additions & 1 deletion pyani/scripts/pyani_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import os

from typing import List, Optional
from pathlib import Path

from pyani.logger import config_logger
from pyani.pyani_tools import termcolor
Expand Down Expand Up @@ -103,8 +104,12 @@ def run_main(argv: Optional[List[str]] = None) -> int:
sys.stderr.write(f"{VERSION_INFO}\n")
return 0

# If the command run is not pyani (e.g., `pytest`, then we
# don't want to apply pyani-specific checks)
if len(sys.argv) == 1 and Path(sys.argv[0]).name != "pyani":
return
# Catch requests for citation and version information
if sys.argv[1].startswith("-"):
elif sys.argv[1].startswith("-"):
if args.citation:
sys.stderr.write(f"{VERSION_INFO}\n")
sys.stderr.write("\n".join(CITATION_INFO) + "\n")
Expand Down