Skip to content

Commit

Permalink
touching up tests for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
lockefox committed Mar 3, 2018
1 parent 997e219 commit 70e202b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
23 changes: 11 additions & 12 deletions prosper/common/prosper_version.py
Expand Up @@ -10,21 +10,20 @@

import semantic_version

import prosper.common.exceptions as exceptions
from . import exceptions

DEFAULT_VERSION = '0.0.0'
DEFAULT_BRANCH = 'master'
TEST_MODE = False

def get_version(
here_path,
default_version=DEFAULT_VERSION
default_version=DEFAULT_VERSION,
):
"""tries to resolve version number
Args:
here_path (str): path to project local dir
default_version (str, optional): what version to return if all else fails
default_version (str): what version to return if all else fails
Returns:
str: semantic_version information for library
Expand Down Expand Up @@ -59,27 +58,27 @@ def get_version(

def _read_git_tags(
default_version=DEFAULT_VERSION,
git_command=['git', 'tag']
git_command=('git', 'tag'),
):
"""tries to find current git tag
Notes:
git_command exposed for testing null case
Args:
default_version (str, optional): what version to make
git_command (:obj:`list`, optional): subprocess command
default_version (str): what version to make
git_command (:obj:`list`): subprocess command
Retruns:
str: latest version found, or default
Raises:
Warns:
exceptions.ProsperDefaultVersionWarning: git version not found
"""
try: # pragma: no cover
try:
current_tags = check_output(git_command).splitlines()
except Exception:
except Exception: # pragma: no cover
raise

if not current_tags[0]:
Expand All @@ -103,13 +102,13 @@ def _read_git_tags(

def _version_from_file(
path_to_version,
default_version=DEFAULT_VERSION
default_version=DEFAULT_VERSION,
):
"""for PyPI installed versions, just get data from file
Args:
path_to_version (str): abspath to dir where version.txt exists
default_version (str, optional): fallback version in case of error
default_version (str): fallback version in case of error
Returns:
str: current working version
Expand Down
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -148,6 +148,7 @@ def initialize_options(self):
'pytest_cov',
'mock',
'yolk3k',
'coverage',
],
extras_require={
'dev':[
Expand Down
2 changes: 1 addition & 1 deletion tests/test_prosper_cli.py
Expand Up @@ -125,7 +125,7 @@ class TestCLI:
def test_happypath(self):
"""validate output is output"""
# TODO: test isn't working, but OK?
result = self.cli('-v')
result = self.cli('--verbose')
if not result:
pytest.xfail('expected output? `{}`'.format(result))

Expand Down
7 changes: 6 additions & 1 deletion tests/test_prosper_version.py
Expand Up @@ -7,6 +7,7 @@
from os import path
import os
import shutil
import sys
from subprocess import check_output

import pytest
Expand Down Expand Up @@ -135,8 +136,12 @@ def test_version_installed_as_dep():
# Prep a dummy version
virtualenv_name = 'DUMMY_VENV'
dummy_version = '9.9.9'
python_version = 'python{major}.{minor}'.format(
major=sys.version_info[0],
minor=sys.version_info[1]
)
virtualenv_path = path.join(
HERE, virtualenv_name, 'lib/python3.6/site-packages/prosper/common')
HERE, virtualenv_name, 'lib', python_version, 'site-packages/prosper/common')
os.makedirs(virtualenv_path, exist_ok=True)
with open(path.join(virtualenv_path, 'version.txt'), 'w') as dummy_fh:
dummy_fh.write(dummy_version)
Expand Down

0 comments on commit 70e202b

Please sign in to comment.