Skip to content

Commit 1d68a5f

Browse files
committed
test for getting version
1 parent f700980 commit 1d68a5f

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ __pycache__
33
*$py.class
44
*.egg-info
55
build
6-
dist
6+
dist
7+
.idea

config_py/bin/config_py.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717

1818
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
1919

20-
exec(open(os.path.join(
20+
with open(os.path.join(
2121
os.path.dirname(os.path.realpath(__file__)), '..', '..', 'version.py'
22-
)).read())
22+
)) as f:
23+
exec(f.read())
2324

2425

2526
def generate_root_config():

setup.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from os import path
22
from setuptools import setup
33

4-
exec(open(path.join(
5-
path.dirname(path.realpath(__file__)), 'version.py'
6-
)).read())
4+
with open(os.path.join(
5+
os.path.dirname(os.path.realpath(__file__)), '..', '..', 'version.py'
6+
)) as f:
7+
exec(f.read())
78

89
long_description = """
910
A package for managing configuration files in Python applications

test/bin/config_py_test.py

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import shutil
66
from click.testing import CliRunner
77
import filecmp
8+
import re
89

910

1011
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
@@ -99,6 +100,13 @@ def test_create_config_module_fail(self, mock_get_cwd):
99100

100101
self.assertEqual(1, result.exit_code)
101102

103+
def test_get_version(self):
104+
runner = CliRunner()
105+
result = runner.invoke(config_py, ['--version'])
106+
107+
self.assertEqual(0, result.exit_code)
108+
self.assertRegexpMatches(result.output, re.compile('\d\.\d\.\d'))
109+
102110

103111
if __name__ == '__main__':
104112
unittest.main()

0 commit comments

Comments
 (0)