Skip to content
This repository has been archived by the owner on Feb 10, 2021. It is now read-only.

Commit

Permalink
Version 0.8.6
Browse files Browse the repository at this point in the history
CHanged main function behaviour a bit.
  • Loading branch information
hbldh committed Apr 16, 2016
1 parent 384e269 commit a229757
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
5 changes: 5 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v0.8.6 (2016-04-16)
===================
- Changed the main function of `sudokuextract.extract` to print and
not return anything.

v0.8.5 (2016-03-10)
===================
- Replace ndi.binary_fill_holes with a binary_erosion and increased number of blobs to test to 2.
Expand Down
2 changes: 1 addition & 1 deletion sudokuextract/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
# version.
_version_major = 0
_version_minor = 8
_version_patch = 5
_version_patch = 6
# _version_extra = '.dev2'
# _version_extra = 'rc1'
_version_extra = '' # Uncomment this for full releases
Expand Down
2 changes: 0 additions & 2 deletions sudokuextract/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ def main():

preds, images, subimage = extract_sudoku(image)
sudoku_string = predictions_to_suduko_string(preds, args.oneliner)

print(sudoku_string)
return sudoku_string

if __name__ == '__main__':
main()
35 changes: 20 additions & 15 deletions tests/test_se.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,36 +61,40 @@ def _process_an_image(image, correct_sudoku):
assert parsed_sudoku == correct_sudoku


def test_image_1_cmd_1():
def test_image_1_cmd_1(capsys):
"""Test Image 1 via command line tool."""
sys.argv = ['parse-sudoku', '-p', _get_img_path(1)]
parsed_sudoku = main()
main()
out, err = capsys.readouterr()
correct_sudoku = _get_parsed_img(1)
assert parsed_sudoku == correct_sudoku
assert out.strip() == correct_sudoku


def test_image_1_cmd_2():
def test_image_1_cmd_2(capsys):
"""Test Image 1 via command line tool."""
sys.argv = ['parse-sudoku', '-p', _get_img_path(1), '--oneliner']
parsed_sudoku = main()
main()
out, err = capsys.readouterr()
correct_sudoku = _get_parsed_img(1).replace('\n', '')
assert parsed_sudoku == correct_sudoku
assert out.strip() == correct_sudoku


def test_image_2_cmd_1():
def test_image_2_cmd_1(capsys):
"""Test Image 1 via command line tool."""
sys.argv = ['parse-sudoku', '-p', _get_img_path(2)]
parsed_sudoku = main()
main()
out, err = capsys.readouterr()
correct_sudoku = _get_parsed_img(2)
assert parsed_sudoku == correct_sudoku
assert out.strip() == correct_sudoku


def test_image_2_cmd_2():
def test_image_2_cmd_2(capsys):
"""Test Image 2 via command line tool."""
sys.argv = ['parse-sudoku', '-p', _get_img_path(2), '--oneliner']
parsed_sudoku = main()
main()
out, err = capsys.readouterr()
correct_sudoku = _get_parsed_img(2).replace('\n', '')
assert parsed_sudoku == correct_sudoku
assert out.strip() == correct_sudoku


def test_image_1_with_trained_classifier():
Expand Down Expand Up @@ -126,10 +130,11 @@ def test_url_1_straight():
_process_an_image(image, solution)


def test_url_1_via_commandline():
def test_url_1_via_commandline(capsys):
url = "https://static-secure.guim.co.uk/sys-images/Guardian/Pix/pictures/2013/2/27/1361977880123/Sudoku2437easy.jpg"
sys.argv = ['parse-sudoku', '-u', url]
parsed_sudoku = main()
main()
out, err = capsys.readouterr()
solution = ("041006029\n"
"300790000\n"
"009000308\n"
Expand All @@ -139,7 +144,7 @@ def test_url_1_via_commandline():
"403000900\n"
"000032004\n"
"650400730")
assert parsed_sudoku == solution
assert out.strip() == solution


### Parameterized tests
Expand Down

0 comments on commit a229757

Please sign in to comment.