コード例 #1
0
ファイル: test_ipc.py プロジェクト: jwilk/ocrodjvu
 def test1(self):
     child = ipc.Subprocess(['false'])
     with assert_raises(ipc.CalledProcessError) as ecm:
         child.wait()
     message = str(ecm.exception)
     if message[-1] == '.':  # subprocess32 >= 3.5
         message = message[:-1]
     assert_equal(message, "Command 'false' returned non-zero exit status 1")
コード例 #2
0
 def _test_signal(self, name):
     child = ipc.Subprocess(
         ['cat'], stdin=ipc.PIPE)  # Any long-standing process would do.
     os.kill(child.pid, getattr(signal, name))
     with assert_raises(ipc.CalledProcessInterrupted) as ecm:
         child.wait()
     assert_equal(str(ecm.exception),
                  "Command 'cat' was interrupted by signal " + name)
コード例 #3
0
ファイル: test_ipc.py プロジェクト: jwilk/ocrodjvu
 def test_fail(self):
     prog = 'ocrodjvu-nonexistent'
     with assert_raises(OSError) as ecm:
         ipc.require(prog)
     exc_message = "[Errno {errno.ENOENT}] command not found: {cmd!r}".format(
         errno=errno,
         cmd=prog,
     )
     assert_equal(str(ecm.exception), exc_message)
コード例 #4
0
 def test1(self):
     child = ipc.Subprocess(['false'])
     with assert_raises(ipc.CalledProcessError) as ecm:
         child.wait()
     message = str(ecm.exception)
     if message[-1] == '.':  # subprocess32 >= 3.5
         message = message[:-1]
     assert_equal(message,
                  "Command 'false' returned non-zero exit status 1")
コード例 #5
0
 def test_fail(self):
     prog = 'ocrodjvu-nonexistent'
     with assert_raises(OSError) as ecm:
         ipc.require(prog)
     exc_message = "[Errno {errno.ENOENT}] command not found: {cmd!r}".format(
         errno=errno,
         cmd=prog,
     )
     assert_equal(str(ecm.exception), exc_message)
コード例 #6
0
def test_init_exc():
    # https://bugs.python.org/issue32490
    prog = 'ocrodjvu-nonexistent'
    with assert_raises(EnvironmentError) as ecm:
        ipc.Subprocess([prog])
    msg = '[Errno {err}] {strerr}: {prog!r}'.format(err=errno.ENOENT,
                                                    strerr=os.strerror(
                                                        errno.ENOENT),
                                                    prog=prog)
    assert_equal(str(ecm.exception), msg)
コード例 #7
0
ファイル: test_ipc.py プロジェクト: jwilk/ocrodjvu
def test_init_exc():
    # https://bugs.python.org/issue32490
    prog = 'ocrodjvu-nonexistent'
    with assert_raises(EnvironmentError) as ecm:
        ipc.Subprocess([prog])
    msg = '[Errno {err}] {strerr}: {prog!r}'.format(
        err=errno.ENOENT,
        strerr=os.strerror(errno.ENOENT),
        prog=prog
    )
    assert_equal(str(ecm.exception), msg)
コード例 #8
0
ファイル: test_cuneiform.py プロジェクト: jwilk/ocrodjvu
 def _test_recognize(self, lang1, lang2):
     def fake_subprocess(args, *rest, **kwrest):
         # Record arguments that were used and break immediately.
         assert_equal(args[0], self.engine.executable)
         assert_equal(args[1], '-l')
         assert_equal(args[2], lang1)
         raise EOFError
     with interim(lib.ipc, Subprocess=fake_subprocess):
         with assert_raises(EOFError):
             with self.engine.recognize(sys.stdin, lang1):
                 pass
コード例 #9
0
    def _test_recognize(self, lang1, lang2):
        def fake_subprocess(args, *rest, **kwrest):
            # Record arguments that were used and break immediately.
            assert_equal(args[0], self.engine.executable)
            assert_equal(args[1], '-l')
            assert_equal(args[2], lang1)
            raise EOFError

        with interim(lib.ipc, Subprocess=fake_subprocess):
            with assert_raises(EOFError):
                with self.engine.recognize(sys.stdin, lang1):
                    pass
コード例 #10
0
ファイル: test_utils.py プロジェクト: rockclimb/hocr2djvused
 def t():
     with assert_raises(ImportError) as ecm:
         try:
             import nonexistent
         except ImportError as ex:
             enhance_import_error(ex, 'PyNonexistent', None,
                                  'http://pynonexistent.example.net/')
             raise
         nonexistent.f()  # quieten pyflakes
     assert_equal(
         str(ecm.exception), 'No module named nonexistent; '
         'please install the PyNonexistent package <http://pynonexistent.example.net/>'
     )
コード例 #11
0
ファイル: test_utils.py プロジェクト: rockclimb/hocr2djvused
 def test_debian(self):
     with interim(lib.utils, debian=True):
         with assert_raises(ImportError) as ecm:
             try:
                 import nonexistent
             except ImportError as ex:
                 enhance_import_error(ex, 'PyNonexistent',
                                      'python-nonexistent',
                                      'http://pynonexistent.example.net/')
                 raise
             nonexistent.f()  # quieten pyflakes
         assert_equal(
             str(ecm.exception), 'No module named nonexistent; '
             'please install the python-nonexistent package')
コード例 #12
0
ファイル: test_ipc.py プロジェクト: jwilk/ocrodjvu
 def _test_signal(self, name):
     child = ipc.Subprocess(['cat'], stdin=ipc.PIPE)  # Any long-standing process would do.
     os.kill(child.pid, getattr(signal, name))
     with assert_raises(ipc.CalledProcessInterrupted) as ecm:
         child.wait()
     assert_equal(str(ecm.exception), "Command 'cat' was interrupted by signal " + name)
コード例 #13
0
 def test1(self):
     child = ipc.Subprocess(['false'])
     with assert_raises(ipc.CalledProcessError) as ecm:
         child.wait()
     assert_equal(str(ecm.exception),
                  "Command 'false' returned non-zero exit status 1")