Skip to content

Commit

Permalink
Fixed a few developer gotchas
Browse files Browse the repository at this point in the history
- Update the run_tests.py script to ensure that the correct version of the
  'ksconf' package is used for testing rather than any-old version that may
  have been previously installed.  Before this should have been the default
  behavior, but it could have failed if running this script from a different
  working directory.
- Fix long-standing issue with local pre-commit hooks where make_cli_docs and
  unittest were always run, even if there were no changes to python files.
  Caused by a typo.
- Fix entrypoint fallback missing functionality (I think ONLY used by a
  unittest, but for the entire 2 mins it took to implement, it's done.)
- Bump pre-commit repo to latest version of the hooks.
  • Loading branch information
lowell80 committed Feb 5, 2019
1 parent 0c11832 commit 8957fc5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See http://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
sha: v1.4.0
sha: v2.0.0
hooks:
- id: trailing-whitespace
exclude: \.md$
Expand All @@ -24,13 +24,13 @@ repos:
name: Generating CLI reference docs -> docs/source/cli.md
language: script
entry: make_cli_docs.py
type: [ python ]
types: [ python ]
pass_filenames: false
- id: ksconf-unittest
name: Run all unit tests for ksconf
language: script
entry: run_tests.py
type: [ python ]
types: [ python ]
pass_filenames: false

# Way too much noise.... (or I just have bad code, either way it's too much)
Expand Down
7 changes: 5 additions & 2 deletions ksconf/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,11 @@ def _get_pkgresources_lib(group, name=None):

def _get_fallback(group, name=None):
from ksconf.setup_entrypoints import get_entrypoints_fallback
if name: raise NotImplementedError
return get_entrypoints_fallback(group)
entrypoints = get_entrypoints_fallback(group)
if name is None:
return entrypoints
else:
return entrypoints[name]

# Removed _get_pkgresources_lib as middle option
__get_entity_resolvers = [ _get_entrypoints_lib, _get_fallback ]
Expand Down
7 changes: 7 additions & 0 deletions run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
import sys
import unittest

# Run tests from this working directory; not from a previous 'pip install' run.
home = os.path.dirname(os.path.abspath(sys.argv[0] or __file__))
sys.path.insert(0, home)

import ksconf
print("Running all KSCONF unit tests. KSCONF home: {}".format(ksconf.__path__[0]))

# Because this script is run from the 'pre-commit' hooks, and some of these
# unittests do git automation, we need to purge all the "GIT_*" variables
for k in list(os.environ):
Expand Down

0 comments on commit 8957fc5

Please sign in to comment.