Skip to content
This repository was archived by the owner on Nov 26, 2021. It is now read-only.

Commit cf9ea17

Browse files
committed
Simplified unit tests
1 parent 56e6a8b commit cf9ea17

File tree

6 files changed

+16
-23
lines changed

6 files changed

+16
-23
lines changed

.coveragerc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
exclude_lines =
33
if __name__ == '__main__':
44
main()
5+
DiffCLI()

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## v1.3.1 (2020-08-26)
4+
5+
* Simplified unit tests
6+
37
## v1.3.0 (2020-08-20)
48

59
* Overhauled testing suite (less exclusions, more robust tests)

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ clean:
2121
rm -rf build
2222
rm -rf *.egg-info
2323

24+
## run - Run the project
25+
run:
26+
venv/bin/python diff/diff_files.py
27+
2428
## lint - Lint the project
2529
lint:
2630
venv/bin/flake8 diff/*.py

diff/diff_files.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,21 @@ def __init__(self):
1212
parser.add_argument(
1313
'-f1',
1414
'--file1',
15+
type=argparse.FileType('r'),
1516
required=True,
1617
help='The output to the base file to compare a second file to.'
1718
)
1819
parser.add_argument(
1920
'-f2',
2021
'--file2',
22+
type=argparse.FileType('r'),
2123
required=True,
2224
help='The output to the second file compared to the base file.'
2325
)
2426
parser.add_argument(
2527
'-o',
2628
'--output',
29+
type=argparse.FileType('w'),
2730
required=False,
2831
default='diff.html',
2932
help='The output to the output file including filename.'

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name='diff-tool',
8-
version='1.3.0',
8+
version='1.3.1',
99
description='Display a diff between two files in HTML.',
1010
long_description=long_description,
1111
long_description_content_type="text/markdown",

test/unit/test_diff.py

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,13 @@
11
import mock
2-
import pytest
3-
import argparse
42
from diff import diff_files
53

64

7-
@mock.patch('argparse.ArgumentParser.parse_args',
8-
return_value=argparse.Namespace(
9-
file1='file1.txt',
10-
file2='file2.txt',
11-
output='output.html',
12-
)
13-
)
14-
def test_cli(mock_args):
15-
diff_files.DiffCLI()
16-
17-
18-
@pytest.mark.skip('Skipping this test until we can mock "self" in argparse.')
19-
def test_cli_run():
20-
raise Exception('TODO: finish this test')
21-
22-
235
def test_diff_run():
24-
diff_file = 'test/files/diff.html'
256
with mock.patch('builtins.open', mock.mock_open()):
267
result = diff_files.Diff.run(
27-
'test/files/file1.txt',
28-
'test/files/file2.txt',
29-
diff_file,
8+
'file1.txt',
9+
'file2.txt',
10+
'output.html'
3011
)
3112
assert '<!DOCTYPE html' in result
3213

0 commit comments

Comments
 (0)