<NME> test_gs.py
<BEF> #from pypdfocr import PyPDFOCR as P
import pypdfocr.pypdfocr_gs as P
import pytest
import os

import hashlib

from mock import patch, call
from pytest import skip

class TestGS:

    @pytest.mark.skipif(os.name!='nt', reason="Not on NT")
    @patch('os.name')
    @patch('subprocess.check_output')
    def test_gs_set_nt(self, mock_subprocess, mock_os_name):
        """
            Check that we have a exe on windows
        """
        mock_os_name.__str__.return_value = 'nt'
        p = P.PyGs({})

        assert 'gswin' in p.binary

    @pytest.mark.skipif(os.name!='nt', reason="Not on NT")
    @patch('os.name')
    @patch('subprocess.call')
    def test_gs_run_nt(self, mock_subprocess, mock_os_name, capsys):
        """
            Stupid test because Windows Tesseract only returns 3.02 instead of 3.02.02
        """
        mock_os_name.__str__.return_value = 'nt'
        p = P.PyGs({})

        mock_subprocess.return_value = -1
        p.binary = 'gsblah.exe'
        with pytest.raises(SystemExit):
            p._run_gs("","","")

        out,err = capsys.readouterr()
        assert p.msgs['GS_FAILED'] in out

    def test_gs_pdf_missing(self, capsys):
        p = P.PyGs()
        with pytest.raises(SystemExit):
            p.make_img_from_pdf("missing123.pdf", "")
        out,err = capsys.readouterr()
        assert p.msgs['GS_MISSING_PDF'] in out



<MSG> Wrapped watch in exception handling so nothing should terminate it except ctrl-c

<DFF> @@ -43,7 +43,7 @@ class TestGS:
     def test_gs_pdf_missing(self, capsys):
         p = P.PyGs()
         with pytest.raises(SystemExit):
-            p.make_img_from_pdf("missing123.pdf", "")
+            p.make_img_from_pdf("missing123.pdf")
         out,err = capsys.readouterr()
         assert p.msgs['GS_MISSING_PDF'] in out
 

{'addition_count': 1, 'commit_subject': 'Wrapped watch in exception handling so nothing should terminate it except ctrl-c', 'deletion_count': 1, 'file_extension': '.py', 'lang': 'py', 'license': 'apache-2.0', 'repo_name': 'virantha/pypdfocr'}