Commit cf189ee5 authored by Willi Rath's avatar Willi Rath

Put version setting to a function

parent 607e13fd
......@@ -9,12 +9,31 @@ import stat
import textwrap
import yaml
def maybe_get_installed_version(pkg_name):
"""If `pkg_name` is installed, set version from there.
pkg_name : str
Package name.
version : str
Version number from installed package or 'vX.X.X'
version = get_distribution(pkg_name).version
except DistributionNotFound:
# package is not installed
version = "vX.X.X"
return version
# Set version string
__version__ = get_distribution(__name__).version
except DistributionNotFound:
# package is not installed
__version__ = "vX.X.X"
__version__ = maybe_get_installed_version(__name__)
class Renderer(object):
# -*- coding:utf-8 -*-
import data_repo_renderer
import pytest
def test_generic_version_if_not_installed():
vers = data_repo_renderer.maybe_get_installed_version("datareporenderer")
assert vers == "vX.X.X"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment