Skip to content
This repository has been archived by the owner on Oct 24, 2020. It is now read-only.

Commit

Permalink
Merge pull request #27 from cisagov/lineage/skeleton
Browse files Browse the repository at this point in the history
⚠️ CONFLICT! Lineage pull request for: skeleton
  • Loading branch information
mcdonnnj committed Oct 23, 2020
2 parents 0476aed + 9a4231b commit 7c2f61a
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 26 deletions.
5 changes: 0 additions & 5 deletions .isort.cfg
Expand Up @@ -6,10 +6,5 @@ import_heading_stdlib=Standard Python Libraries
import_heading_thirdparty=Third-Party Libraries
import_heading_firstparty=cisagov Libraries

# Should be auto-populated by seed-isort-config hook
known_third_party=docopt,pytest,schema,setuptools,urllib3
# These must be manually set to correctly separate them from third party libraries
known_first_party=check_cve

# Run isort under the black profile to align with our other Python linting
profile=black
22 changes: 9 additions & 13 deletions .pre-commit-config.yaml
Expand Up @@ -27,21 +27,21 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.23.2
rev: v0.24.0
hooks:
- id: markdownlint
args:
- --config=.mdl_config.json
- repo: https://github.com/adrienverge/yamllint
rev: v1.24.2
rev: v1.25.0
hooks:
- id: yamllint
- repo: https://github.com/detailyang/pre-commit-shell
rev: 1.0.5
hooks:
- id: shell-lint
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
rev: 3.8.4
hooks:
- id: flake8
additional_dependencies:
Expand Down Expand Up @@ -70,21 +70,17 @@ repos:
rev: 20.8b1
hooks:
- id: black
- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
hooks:
- id: seed-isort-config
- repo: https://github.com/timothycrosley/isort
rev: 5.5.0
rev: 5.6.4
hooks:
- id: isort
- repo: https://github.com/ansible/ansible-lint.git
rev: v4.3.4
rev: v4.3.5
hooks:
- id: ansible-lint
# files: molecule/default/playbook.yml
- repo: https://github.com/antonbabenko/pre-commit-terraform.git
rev: v1.37.0
rev: v1.43.0
hooks:
- id: terraform_fmt
# There are ongoing issues with how this command works. This issue
Expand All @@ -107,11 +103,11 @@ repos:
rev: v2.0.0
hooks:
- id: docker-compose-check
- repo: https://github.com/prettier/prettier
rev: 2.1.1
- repo: https://github.com/prettier/pre-commit
rev: v2.1.2
hooks:
- id: prettier
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.782
rev: v0.790
hooks:
- id: mypy
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -75,7 +75,7 @@ Options:

## Contributing ##

We welcome contributions! Please see [here](CONTRIBUTING.md) for
We welcome contributions! Please see [`CONTRIBUTING.md`](CONTRIBUTING.md) for
details.

## License ##
Expand Down
2 changes: 1 addition & 1 deletion setup.py
@@ -1,5 +1,5 @@
"""
This is the setup module for the example project.
This is the setup module for the check-cve-2019-19781 project.
Based on:
Expand Down
5 changes: 5 additions & 0 deletions src/check_cve/__main__.py
@@ -0,0 +1,5 @@
"""Code to run if this package is used as a Python module."""

from .check import main

main()
6 changes: 0 additions & 6 deletions src/check_cve/check.py 100755 → 100644
@@ -1,5 +1,3 @@
#!/usr/bin/env python

"""Check for the existence of CVE-2019-19781 on a host machine.
EXIT STATUS
Expand Down Expand Up @@ -127,7 +125,3 @@ def main():
# Stop logging and clean up
logging.shutdown()
return result


if __name__ == "__main__":
sys.exit(main())
17 changes: 17 additions & 0 deletions tests/test_check_cve.py
Expand Up @@ -40,6 +40,23 @@ def test_stdout_version(capsys):
), "standard output by '--version' should agree with module.__version__"


def test_running_as_module(capsys):
"""Verify that the __main__.py file loads correctly."""
with pytest.raises(SystemExit):
with patch.object(sys, "argv", ["bogus", "--version"]):
# F401 is a "Module imported but unused" warning. This import
# emulates how this project would be run as a module. The only thing
# being done by __main__ is importing the main entrypoint of the
# package and running it, so there is nothing to use from this
# import. As a result, we can safely ignore this warning.
# cisagov Libraries
import check_cve.__main__ # noqa: F401
captured = capsys.readouterr()
assert (
captured.out == f"{PROJECT_VERSION}\n"
), "standard output by '--version' should agree with module.__version__"


@pytest.mark.skipif(
RELEASE_TAG in [None, ""], reason="this is not a release (RELEASE_TAG not set)"
)
Expand Down

0 comments on commit 7c2f61a

Please sign in to comment.