This repository was archived by the owner on Nov 26, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +16
-23
lines changed
Expand file tree Collapse file tree 6 files changed +16
-23
lines changed Original file line number Diff line number Diff line change 22exclude_lines =
33 if __name__ == ' __main__' :
44 main()
5+ DiffCLI()
Original file line number Diff line number Diff line change 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)
Original file line number Diff line number Diff 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
2529lint :
2630 venv/bin/flake8 diff/* .py
Original file line number Diff line number Diff 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.'
Original file line number Diff line number Diff line change 55
66setuptools .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" ,
Original file line number Diff line number Diff line change 11import mock
2- import pytest
3- import argparse
42from 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-
235def 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
You can’t perform that action at this time.
0 commit comments