Esempio n. 1
0
 def test_execution_time(self):
     enable_socket()
     text_and_time = OcrTable(self.image_path, show_performace=True)
     has_time = text_and_time.execution_time and \
         text_and_time.show_performace and \
         len(ast.literal_eval(repr(text_and_time))) > 1
     self.assertTrue(has_time)
Esempio n. 2
0
def socket_enabled(pytestconfig):
    """Enable socket.socket for duration of this test function.

    This incorporates changes from https://github.com/miketheman/pytest-socket/pull/76
    and hardcodes allow_unix_socket to True because it's not passed on the command line.
    """
    socket_was_disabled = socket.socket != pytest_socket._true_socket
    pytest_socket.enable_socket()
    yield
    if socket_was_disabled:
        disable_socket(allow_unix_socket=True)
Esempio n. 3
0
def test_loadBioNLP_fail():
    pytest_socket.disable_socket()
    with pytest.raises(RuntimeError) as excinfo:
        corpus = kindred.bionlpst.load('2016-BB3-event-train')
    pytest_socket.enable_socket()
    assert excinfo.value.args == ('A test tried to use socket.socket.', )
Esempio n. 4
0
 def test_get_model(self):
     enable_socket()
     if os.path.isfile(self.model_path):
         os.remove(self.model_path)
     model = aux.get_model_from_s3(self.model_path)
     self.assertTrue(isinstance(model, str))
Esempio n. 5
0
 def test_load_model(self):
     enable_socket()
     model = aux.load_east_model()
     self.assertTrue(isinstance(model, str))
Esempio n. 6
0
 def test_url_type(self):
     enable_socket()
     url = 'https://img.icons8.com/all/500/general-ocr.png'
     input_type = aux.get_input_type(url)
     self.assertEqual(input_type, 1)
Esempio n. 7
0
 def test_image_processing(self):
     enable_socket()
     image = Image.open(self.image_path)
     text = OcrTable(image)
     type_output = isinstance(text.text, str)
     self.assertTrue(type_output)
Esempio n. 8
0
 def test_url_processing(self):
     enable_socket()
     text = OcrTable('https://project-elements-nk.s3.amazonaws.com/ocr.png')
     type_output = isinstance(text.text, str)
     self.assertTrue(type_output)
Esempio n. 9
0
def reenable_socket():
    # The tests can leave the socket disabled in the global scope.
    # Fix that by automatically re-enabling it after each test
    yield
    enable_socket()
Esempio n. 10
0
def pytest_enable_socket():
    enable_socket()